Skip to content
Myr

Implement per-host proxies

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

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

authored by Jason Grout · committed by Jason Grout · parent cef2589 · Browse files · 1 file+2 added−1 removed
This commit

State

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

Diff stats

1 file+2 added−1 removed

  • other:+2 added−1 removed

1 file+2 added−1 removed

modified:requests/adapters.py+2 added-1 removed
237 unmodified lines
238 :param url: The URL to connect to.239 :param proxies: (optional) A Requests-style dictionary of proxies used on this request.240 """241 proxies = proxies or {}242 proxy = proxies.get(urlparse(url.lower()).scheme)242 u = urlparse(url.lower())243 proxy = proxies.get(u.scheme+'://'+u.hostname, proxies.get(u.scheme))244245 if proxy:246 proxy = prepend_scheme_if_needed(proxy, 'http')247 proxy_manager = self.proxy_manager_for(proxy)
188 unmodified lines