mirror of
https://opendev.org/x/pyghmi
synced 2025-01-30 21:07:40 +00:00
Force body to str for json
Some versions of python cannot take bytes for the json payload. Workaround by explicitly decoding from utf8 in such a case. Change-Id: Idb86003fcf6643e5c67e13202de41be6c35607a0
This commit is contained in:
parent
39a1fa0985
commit
b48cdba5f3
@ -228,6 +228,8 @@ class SecureHTTPConnection(httplib.HTTPConnection, object):
|
||||
if rsp.getheader('Content-Encoding', None) == 'gzip':
|
||||
body = gzip.GzipFile(fileobj=io.BytesIO(body)).read()
|
||||
if rsp.status >= 200 and rsp.status < 300:
|
||||
if body and not isinstance(body, str):
|
||||
body = body.decode('utf8')
|
||||
return json.loads(body) if body else {}, rsp.status
|
||||
return body, rsp.status
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user