Skip to content
Myr

resolve_redirects now checks for a scheme before converting the scheme to lowercase, added tests or the scheme casing

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Bob Carroll · committed by Bob Carroll · parent e715d71 · Browse files · 2 files+11 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−2 removed

  • other:+11 added−2 removed

2 files+11 added−2 removed

modified:requests/sessions.py+3 added-2 removed
96 unmodified lines
97 parsed_rurl = urlparse(resp.url)98 url = '%s:%s' % (parsed_rurl.scheme, url)99100 # The scheme should be lower case...101 if '://' in url:101 scheme, uri = url.split('://')102 url = '%s://%s' % (scheme.lower(), uri)102 scheme, uri = url.split('://', 1)103 url = '%s://%s' % (scheme.lower(), uri)104105 # Facilitate non-RFC2616-compliant 'location' headers106 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')107 # Compliant with RFC3986, we percent encode the url.
399 unmodified lines
modified:test_requests.py+8 added
493 unmodified lines
494 self.assertEqual(495 headers['ACCEPT'.encode('ascii')],496 'application/json'497 )498 def test_uppercase_scheme(self):499 r = requests.get('HTTP://example.com/')500 self.assertEqual(r.status_code, 200)501502 def test_transport_adapter_ordering(self):503 s = requests.Session()504 order = ['https://', 'http://']
199 unmodified lines
704 self.assertEqual(frozenset(cid.keys()), keyset)705 self.assertEqual(frozenset(cid), keyset)706707708709 def test_uppercase_scheme_redirect(self):710 r = requests.get(httpbin('redirect-to'), params={'url': 'HTTP://example.com/'})711712713if __name__ == '__main__':714 unittest.main()