Always percent-encode location headers.
authorCory Benfield <lukasaoz@gmail.com>
Thu, 16 May 2013 10:58:18 +0000 (11:58 +0100)
committerCory Benfield <lukasaoz@gmail.com>
Thu, 16 May 2013 11:02:46 +0000 (12:02 +0100)
requests/sessions.py

index 77df0e8..a881924 100644 (file)
@@ -111,9 +111,11 @@ class SessionRedirectMixin(object):
 
             # Facilitate non-RFC2616-compliant 'location' headers
             # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
+            # Compliant with RFC3986, we percent encode the url.
             if not urlparse(url).netloc:
-                # Compliant with RFC3986, we percent encode the url.
                 url = urljoin(resp.url, requote_uri(url))
+            else:
+                url = requote_uri(url)
 
             prepared_request.url = url