diff options
author | Ben Sturmfels <ben@sturm.com.au> | 2016-01-19 23:53:52 +1100 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-01-21 10:53:54 -0800 |
commit | 2fdc14a2424d7687358598441db8bcfd8fe9eb69 (patch) | |
tree | 7e3ec35ec1a0e915831944b551c4a9447f452e0d /mediagoblin/tools/request.py | |
parent | 4c77f3d56396a78f2708e59b9cb6c8f150b39b6d (diff) | |
download | mediagoblin-2fdc14a2424d7687358598441db8bcfd8fe9eb69.tar.lz mediagoblin-2fdc14a2424d7687358598441db8bcfd8fe9eb69.tar.xz mediagoblin-2fdc14a2424d7687358598441db8bcfd8fe9eb69.zip |
trac#5397: Allow decode_request to parse content-type headers with extra options.
It previously parsed "Content-Type: application/x-www-form-urlencoded", but not "Content-Type: application/x-www-form-urlencoded; charset=utf-8".
Diffstat (limited to 'mediagoblin/tools/request.py')
-rw-r--r-- | mediagoblin/tools/request.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mediagoblin/tools/request.py b/mediagoblin/tools/request.py index d2cb0f6a..af06967b 100644 --- a/mediagoblin/tools/request.py +++ b/mediagoblin/tools/request.py @@ -17,6 +17,8 @@ import json import logging +from werkzeug.http import parse_options_header + from mediagoblin.db.models import User, AccessToken from mediagoblin.oauth.tools.request import decode_authorization_header @@ -60,10 +62,11 @@ def setup_user_in_request(request): def decode_request(request): """ Decodes a request based on MIME-Type """ data = request.data + content_type, _ = parse_options_header(request.content_type) - if request.content_type == json_encoded: + if content_type == json_encoded: data = json.loads(data) - elif request.content_type == form_encoded or request.content_type == "": + elif content_type == form_encoded or content_type == "": data = request.form else: data = "" |