mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
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>
|
||||
|
||||
@@ -325,6 +325,8 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
"""Prepares the given HTTP headers."""
|
||||
|
||||
if headers:
|
||||
if is_py2:
|
||||
headers = dict((builtin_str(name), value) for name, value in headers.items())
|
||||
self.headers = CaseInsensitiveDict(headers)
|
||||
else:
|
||||
self.headers = CaseInsensitiveDict()
|
||||
|
||||
+5
-1
@@ -10,7 +10,7 @@ import unittest
|
||||
|
||||
import requests
|
||||
from requests.auth import HTTPDigestAuth
|
||||
from requests.compat import str
|
||||
from requests.compat import is_py2, str
|
||||
|
||||
try:
|
||||
import StringIO
|
||||
@@ -251,6 +251,10 @@ class RequestsTestCase(unittest.TestCase):
|
||||
requests.get(url, params={'foo': 'foo'})
|
||||
requests.get(httpbin('ø'), params={'foo': 'foo'})
|
||||
|
||||
def test_unicode_header_name(self):
|
||||
if is_py2:
|
||||
requests.put(httpbin('put'), headers={unicode('Content-Type'): 'application/octet-stream'}, data='\xff')
|
||||
|
||||
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