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:
Fabio Manganiello 2018-07-19 20:07:15 +02:00
parent 72543c26a9
commit bc895dd984

View file

@ -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