Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def request(self, uri, method="GET", body=b'', headers=None,
DEFAULT_POST_CONTENT_TYPE)

is_form_encoded = \
headers.get('Content-Type') == 'application/x-www-form-urlencoded'
headers.get('Content-Type', '').startswith('application/x-www-form-urlencoded')

if is_form_encoded and body:
parameters = parse_qs(body)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,14 @@ def test_multiple_values_for_a_key(self, mockReqConstructor, mockHttpRequest):
self.assertTrue('multi=1' in mockHttpRequest.call_args[1]['body'])
self.assertTrue('multi=2' in mockHttpRequest.call_args[1]['body'])

def test_form_encoded_post_with_charset_in_content_type(self):
client = oauth.Client(self.consumer, None)
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
resp, content = client.request(self._uri('request_token'), "POST",
headers=headers, body='param1=test1&param2=test2')
self.assertEqual(int(resp['status']), 200)


if __name__ == "__main__":
import os
import sys
Expand Down