Commit 445ce13e authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[py3] Decode request's content before JSON loading it

In Python3, json.load() only accepts text content. So we decode
_cw.content's value using request's encoding before passing it to
json.load(). As a consequence of using .getvalue() on BytesIO (content
is a BytesIO), we no longer need to .seek() after reading the content.
parent 35e5a74d2bcc
......@@ -107,8 +107,8 @@ class RqlIOController(Controller):
contenttype = self._cw.get_header('Content-Type', raw=False)
if (contenttype.mediaType, contenttype.mediaSubtype) == ('application', 'json'): # noqa: E501
encoding = contenttype.params.get('charset', 'utf-8')
args = json.load(self._cw.content, encoding=encoding)
self._cw.content.seek(0, 0)
content = self._cw.content.getvalue().decode(encoding)
args = json.loads(content)
else:
args = json.load(self._cw.form['json'][1])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment