Deleted is_py2 check from unicode_header_name fix thanks to Lukasa.
authorDenis Ryzhkov <denisr@denisr.com>
Tue, 12 Feb 2013 06:51:46 +0000 (09:51 +0300)
committerDenis Ryzhkov <denisr@denisr.com>
Tue, 12 Feb 2013 06:51:46 +0000 (09:51 +0300)
requests/models.py
test_requests.py

index 2ca5faa40ff1b741589427db407553a4e6fe694e..4120a8eeb1b97da9de3157b4c769c32045d5bb16 100644 (file)
@@ -325,8 +325,7 @@ 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())
+            headers = dict((name.encode('ascii'), value) for name, value in headers.items())
             self.headers = CaseInsensitiveDict(headers)
         else:
             self.headers = CaseInsensitiveDict()
index e506ffaecf551f2df7ab99cb7a9587537628afe8..e12722d1aeee93ced492d68e3ad8739b301fdaf8 100644 (file)
@@ -10,7 +10,7 @@ import unittest
 
 import requests
 from requests.auth import HTTPDigestAuth
-from requests.compat import is_py2, str
+from requests.compat import str
 
 try:
     import StringIO
@@ -252,8 +252,7 @@ class RequestsTestCase(unittest.TestCase):
         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')
+        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):