forked from platypush/platypush
If the http.request plugin gets a proper JSON message as a response, then extract the Platypush message out of the original response
This commit is contained in:
parent
72543c26a9
commit
bc895dd984
1 changed files with 7 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from platypush.message import Message
|
||||||
from platypush.plugins import Plugin, action
|
from platypush.plugins import Plugin, action
|
||||||
|
|
||||||
class HttpRequestPlugin(Plugin):
|
class HttpRequestPlugin(Plugin):
|
||||||
|
@ -53,6 +54,12 @@ class HttpRequestPlugin(Plugin):
|
||||||
if output == 'binary': output = response.content
|
if output == 'binary': output = response.content
|
||||||
else: output = response.text
|
else: output = response.text
|
||||||
|
|
||||||
|
try:
|
||||||
|
# If the response is a Platypush JSON, extract it
|
||||||
|
output = Message.build(output)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue