Skip to content
Myr

Merge pull request #1334 from rcarz/master

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

resolve_redirects no longer throws an InvalidSchema exception when the scheme is uppercase

authored by Kenneth Reitz · committed by Kenneth Reitz · parents d4c4610, 2c5ea69 · Browse files · 3 files+14 added−0 removed
This commit

State

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

Diff stats

3 files+14 added−0 removed

  • other:+14 added−0 removed

3 files+14 added−0 removed

modified:requests/sessions.py+5 added
95 unmodified lines
96 if url.startswith('//'):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: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.108 if not urlparse(url).netloc:
398 unmodified lines
modified:AUTHORS.rst+1 added
123 unmodified lines
124- Wilfred Hughes <me@wilfred.me.uk> @dontYetKnow125- Dmitry Medvinsky <me@dmedvinsky.name>126- Bryce Boe <bbzbryce@gmail.com> @bboe127- Colin Dunklau <colin.dunklau@gmail.com> @cdunklau128- Bob Carroll <bob.carroll@alum.rit.edu> @rcarz129- Hugo Osvaldo Barrera <hugo@osvaldobarrera.com.ar> @hobarrera130- Łukasz Langa <lukasz@langa.pl> @llanga131- Dave Shawley <daveshawley@gmail.com>
modified:test_requests.py+8 added
522 unmodified lines
523 headers['ACCEPT'.encode('ascii')],524 'application/json'525 )526527 def test_uppercase_scheme(self):528 r = requests.get('HTTP://example.com/')529 self.assertEqual(r.status_code, 200)530531 def test_uppercase_scheme_redirect(self):532 r = requests.get(httpbin('redirect-to'), params={'url': 'HTTP://example.com/'})533 self.assertEqual(r.status_code, 200)534535 def test_transport_adapter_ordering(self):536 s = requests.Session()537 order = ['https://', 'http://']538 self.assertEqual(order, list(s.adapters))
204 unmodified lines