From 56f4b7ca68d75795112b673673de2b90f05c9e93 Mon Sep 17 00:00:00 2001 From: Denis Ryzhkov Date: Tue, 12 Feb 2013 09:51:46 +0300 Subject: [PATCH] Deleted is_py2 check from unicode_header_name fix thanks to Lukasa. --- requests/models.py | 3 +-- test_requests.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/requests/models.py b/requests/models.py index 2ca5faa..4120a8e 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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() diff --git a/test_requests.py b/test_requests.py index e506ffa..e12722d 100644 --- a/test_requests.py +++ b/test_requests.py @@ -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): -- 2.7.4