From 4d9809d2a8c4149ab84161ed6d9f31365da919b9 Mon Sep 17 00:00:00 2001 From: Greg Thornton Date: Sat, 4 Jul 2020 01:38:02 -0500 Subject: [PATCH] Fix send method of socket client implementations --- octorest/websocket.py | 2 +- octorest/xhrstreaming.py | 2 +- octorest/xhrstreaminggenerator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/octorest/websocket.py b/octorest/websocket.py index 5cf3ac6..c6fec59 100644 --- a/octorest/websocket.py +++ b/octorest/websocket.py @@ -52,4 +52,4 @@ def send(self, data): Sends data, currently not working properly. OctoPrint server is unable to parse. """ - self.socket.send(json.dumps(data)) + self.socket.send(json.dumps([json.dumps(data)])) diff --git a/octorest/xhrstreaming.py b/octorest/xhrstreaming.py index 03fcddc..4cf68ee 100644 --- a/octorest/xhrstreaming.py +++ b/octorest/xhrstreaming.py @@ -69,5 +69,5 @@ def send(self, data): print("SENDING") url = self.url.format(protocol="https" if self.secure else "http", method="xhr_send") - response = self.socket.post(url, data=json.dumps(data)) + response = self.socket.post(url, data=json.dumps([json.dumps(data)])) return response diff --git a/octorest/xhrstreaminggenerator.py b/octorest/xhrstreaminggenerator.py index 4e3bd20..fdfdadd 100644 --- a/octorest/xhrstreaminggenerator.py +++ b/octorest/xhrstreaminggenerator.py @@ -64,5 +64,5 @@ def send(self, data): OctoPrint server returns 404 """ url = '/'.join((self.url, 'xhr_send')) - response = self.session.post(url, data=json.dumps(data)) + response = self.session.post(url, data=json.dumps([json.dumps(data)])) return response