mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Implement per-host proxies
This change allows the proxy dict to be have entries of the form
{'<scheme>://<hostname>': '<proxy>'}. Host-specific proxies will be used in
preference to the scheme-specific proxies (i.e., proxy dict entries with keys
like 'http' or 'https').
Fixes #2722
This commit is contained in:
@@ -239,7 +239,8 @@ class HTTPAdapter(BaseAdapter):
|
||||
:param proxies: (optional) A Requests-style dictionary of proxies used on this request.
|
||||
"""
|
||||
proxies = proxies or {}
|
||||
proxy = proxies.get(urlparse(url.lower()).scheme)
|
||||
u = urlparse(url.lower())
|
||||
proxy = proxies.get(u.scheme+'://'+u.hostname, proxies.get(u.scheme))
|
||||
|
||||
if proxy:
|
||||
proxy = prepend_scheme_if_needed(proxy, 'http')
|
||||
|
||||
Reference in New Issue
Block a user