Clarify the per-host proxy code

This commit is contained in:
Jason Grout
2015-08-25 18:21:20 +00:00
parent 618514231b
commit 22075f02d0
+4 -2
View File
@@ -239,8 +239,10 @@ class HTTPAdapter(BaseAdapter):
:param proxies: (optional) A Requests-style dictionary of proxies used on this request.
"""
proxies = proxies or {}
u = urlparse(url.lower())
proxy = proxies.get(u.scheme+'://'+u.hostname, proxies.get(u.scheme))
urlparts = urlparse(url.lower())
proxy = proxies.get(urlparts.scheme+'://'+urlparts.hostname)
if proxy is None:
proxy = proxies.get(urlparts.scheme)
if proxy:
proxy = prepend_scheme_if_needed(proxy, 'http')