Skip to content
Myr

added tests for mixed-case scheme URLs, changed adapters passing down URLs into urllib3 by lower-ifying them so that the underlying pool manager can effectively pool by scheme as dictionary key

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

authored by Viktor Haag · committed by Viktor Haag · parent 5e94f38 · Browse files · 2 files+16 added−9 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+16 added−9 removed

  • other:+16 added−9 removed

2 files+16 added−9 removed

modified:requests/adapters.py+3 added-3 removed
188 unmodified lines
189 :param url: The URL to connect to.190 :param proxies: (optional) A Requests-style dictionary of proxies used on this request.191 """192 proxies = proxies or {}193 proxy = proxies.get(urlparse(url).scheme)193 proxy = proxies.get(urlparse(url.lower()).scheme)194195 if proxy:196 proxy = prepend_scheme_if_needed(proxy, urlparse(url).scheme)196 proxy = prepend_scheme_if_needed(proxy, urlparse(url.lower()).scheme)197 conn = ProxyManager(self.poolmanager.connection_from_url(proxy))198 else:199 conn = self.poolmanager.connection_from_url(url)199 conn = self.poolmanager.connection_from_url(url.lower())200201 return conn202203 def close(self):
139 unmodified lines
modified:test_requests.py+13 added-6 removed
87 unmodified lines
88 "http://example.com/path?key=value&a=b#fragment")8990 def test_mixed_case_scheme_acceptable(self):91 s = requests.Session()92 r = requests.Request('GET', 'HTTP://httbin.org/get')92 r = requests.Request('GET', 'http://httpbin.org/get')93 r = s.send(r.prepare())94 self.assertEqual(r.status_code,200)95 s = requests.Session()95 r = requests.Request('GET', 'hTTp://httbin.org/get')96 r = requests.Request('GET', 'HTTP://httpbin.org/get')97 r = s.send(r.prepare())98 self.assertEqual(r.status_code,200)98 r = requests.Request('GET', 'HttP://httbin.org/get')99 r = requests.Request('GET', 'hTTp://httpbin.org/get')100 r = s.send(r.prepare())101 self.assertEqual(r.status_code,200)101 r = requests.Request('GET', 'HTTPS://httbin.org/get')102 r = requests.Request('GET', 'HttP://httpbin.org/get')103 r = s.send(r.prepare())104 self.assertEqual(r.status_code,200)104 r = requests.Request('GET', 'hTTps://httbin.org/get')105 r = requests.Request('GET', 'https://httpbin.org/get')106 r = s.send(r.prepare())107 self.assertEqual(r.status_code,200)107 r = requests.Request('GET', 'HttPs://httbin.org/get')108 r = requests.Request('GET', 'HTTPS://httpbin.org/get')109 r = s.send(r.prepare())110 self.assertEqual(r.status_code,200)111 r = requests.Request('GET', 'hTTps://httpbin.org/get')112 r = s.send(r.prepare())113 self.assertEqual(r.status_code,200)114 r = requests.Request('GET', 'HttPs://httpbin.org/get')115 r = s.send(r.prepare())116 self.assertEqual(r.status_code,200)117118 def test_HTTP_200_OK_GET_ALTERNATIVE(self):119 r = requests.Request('GET', httpbin('get'))120 s = requests.Session()
614 unmodified lines