diff options
author | Calum Lind <calumlind@gmail.com> | 2018-10-09 14:47:29 +0100 |
---|---|---|
committer | Calum Lind <calumlind@gmail.com> | 2018-10-10 17:57:02 +0100 |
commit | 6f06cd5ebcb7f9505280147260f36d4a324dc758 (patch) | |
tree | 4c15aabbd86dfc61faa952ea916f49a8392bd805 /deluge/ui/web | |
parent | 86de5657ff1a8605e20f8c7beffb8f9e955fcf90 (diff) | |
download | deluge-6f06cd5ebcb7f9505280147260f36d4a324dc758.tar.gz deluge-6f06cd5ebcb7f9505280147260f36d4a324dc758.tar.bz2 deluge-6f06cd5ebcb7f9505280147260f36d4a324dc758.zip |
[WebUI|Py3] Refactor content_type check
Simplify getting content_type from request to prevent str/bytes mixup.
Diffstat (limited to 'deluge/ui/web')
-rw-r--r-- | deluge/ui/web/json_api.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 4ae84bb4c..f11cf3d53 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -194,10 +194,9 @@ class JSON(resource.Resource, component.Component): Handler to take the json data as a string and pass it on to the _handle_request method for further processing. """ - if request.getHeader(b'content-type') != b'application/json': - message = 'Invalid JSON request content-type: %s' % request.getHeader( - 'content-type' - ) + content_type = request.getHeader(b'content-type').decode() + if content_type != 'application/json': + message = 'Invalid JSON request content-type: %s' % content_type raise JSONException(message) log.debug('json-request: %s', request.json) |