From: Bob Carroll Date: Wed, 1 May 2013 06:17:18 +0000 (-0700) Subject: resolve_redirects now checks for a scheme before converting the scheme to lowercase... X-Git-Tag: 2.0~19^2~11^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72e155e529ae9f1892c5dffb5a021fa36ca0243e;p=services%2Fpython-requests.git resolve_redirects now checks for a scheme before converting the scheme to lowercase, added tests or the scheme casing --- diff --git a/requests/sessions.py b/requests/sessions.py index 776f97a..af63d49 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -98,8 +98,9 @@ class SessionRedirectMixin(object): url = '%s:%s' % (parsed_rurl.scheme, url) # The scheme should be lower case... - scheme, uri = url.split('://') - url = '%s://%s' % (scheme.lower(), uri) + if '://' in url: + scheme, uri = url.split('://', 1) + url = '%s://%s' % (scheme.lower(), uri) # Facilitate non-RFC2616-compliant 'location' headers # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource') diff --git a/test_requests.py b/test_requests.py index 4a4831e..5517eda 100755 --- a/test_requests.py +++ b/test_requests.py @@ -495,6 +495,9 @@ class RequestsTestCase(unittest.TestCase): headers['ACCEPT'.encode('ascii')], 'application/json' ) + def test_uppercase_scheme(self): + r = requests.get('HTTP://example.com/') + self.assertEqual(r.status_code, 200) def test_transport_adapter_ordering(self): s = requests.Session() @@ -702,5 +705,10 @@ class TestCaseInsensitiveDict(unittest.TestCase): self.assertEqual(frozenset(cid), keyset) + + def test_uppercase_scheme_redirect(self): + r = requests.get(httpbin('redirect-to'), params={'url': 'HTTP://example.com/'}) + + if __name__ == '__main__': unittest.main()