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
from platypush.message import Message
from platypush.plugins import Plugin, action
class HttpRequestPlugin(Plugin):
@ -53,6 +54,12 @@ class HttpRequestPlugin(Plugin):
if output == 'binary': output = response.content
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