mirror of
https://github.com/kennethreitz/requests3.git
synced 2026-06-05 23:10:16 +00:00
Merge pull request #1181 from denis-ryzhkov/master
Fix of UnicodeDecodeError on unicode header name that can be converted to ascii.
This commit is contained in:
@@ -120,3 +120,4 @@ Patches and Suggestions
|
||||
- David Bonner <dbonner@gmail.com> @rascalking
|
||||
- Vinod Chandru
|
||||
- Johnny Goodnow <j.goodnow29@gmail.com>
|
||||
- Denis Ryzhkov <denisr@denisr.com>
|
||||
|
||||
@@ -323,6 +323,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
"""Prepares the given HTTP headers."""
|
||||
|
||||
if headers:
|
||||
headers = dict((name.encode('ascii'), value) for name, value in headers.items())
|
||||
self.headers = CaseInsensitiveDict(headers)
|
||||
else:
|
||||
self.headers = CaseInsensitiveDict()
|
||||
|
||||
@@ -251,6 +251,9 @@ class RequestsTestCase(unittest.TestCase):
|
||||
requests.get(url, params={'foo': 'foo'})
|
||||
requests.get(httpbin('ø'), params={'foo': 'foo'})
|
||||
|
||||
def test_unicode_header_name(self):
|
||||
requests.put(httpbin('put'), headers={str('Content-Type'): 'application/octet-stream'}, data='\xff') # compat.str is unicode.
|
||||
|
||||
def test_urlencoded_get_query_multivalued_param(self):
|
||||
|
||||
r = requests.get(httpbin('get'), params=dict(test=['foo', 'baz']))
|
||||
|
||||
Reference in New Issue
Block a user