From 7c93fc68c5e1a5ce73a1e9e45ef148506408b95f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 20 Apr 2022 12:35:25 +0200 Subject: [PATCH] fix encode of response in client --- ereuse_devicehub/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/client.py b/ereuse_devicehub/client.py index 31a9f136..aaafb9f3 100644 --- a/ereuse_devicehub/client.py +++ b/ereuse_devicehub/client.py @@ -260,13 +260,15 @@ class UserClientFlask: data=None, follow_redirects=True, content_type='text/html; charset=utf-8', + decode=True, **kw, ): body, status, headers = self.client.get( uri, data=data, follow_redirects=follow_redirects, headers=self.headers ) - body = next(body).decode("utf-8") + if decode: + body = next(body).decode("utf-8") return (body, status) def post( @@ -275,6 +277,7 @@ class UserClientFlask: data=None, follow_redirects=True, content_type='application/x-www-form-urlencoded', + decode=True, **kw, ): @@ -285,5 +288,6 @@ class UserClientFlask: headers=self.headers, content_type=content_type, ) - body = next(body).decode("utf-8") + if decode: + body = next(body).decode("utf-8") return (body, status)