diff --git a/requests/sessions.py b/requests/sessions.py index db227ca3..e262aa32 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -17,7 +17,7 @@ from .cookies import ( cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies) from .models import Request, PreparedRequest from .hooks import default_hooks, dispatch_hook -from .utils import to_key_val_list, default_headers +from .utils import to_key_val_list, default_headers, to_native_string from .exceptions import TooManyRedirects, InvalidSchema from .structures import CaseInsensitiveDict @@ -121,7 +121,7 @@ class SessionRedirectMixin(object): else: url = requote_uri(url) - prepared_request.url = url + prepared_request.url = to_native_string(url) # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4 if (resp.status_code == codes.see_other and diff --git a/test_requests.py b/test_requests.py index 63897bb5..ee9c7b78 100755 --- a/test_requests.py +++ b/test_requests.py @@ -412,6 +412,9 @@ class RequestsTestCase(unittest.TestCase): 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_pyopenssl_redirect(self): + requests.get('https://httpbin.org/status/301') + def test_urlencoded_get_query_multivalued_param(self): r = requests.get(httpbin('get'), params=dict(test=['foo', 'baz']))