Some code cleanups.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Cory Benfield · committed by Cory Benfield · parent 1c54014 · Browse files · 1 file·+25 added−23 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+25 added−23 removed
- other:+25 added−23 removed
Provenance
- Commit
11b9b24- Tree
b77f4dc- Author
Cory Benfield <lukasaoz@gmail.com>- Committer
Cory Benfield <lukasaoz@gmail.com>- Parent
1c54014
1 file changed+25 added−23 removed
modified:requests/adapters.py+25 added-23 removed
17 unmodified lines18 from .packages.urllib3.util.retry import Retry19 from .compat import urlparse, basestring20 from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,21 prepend_scheme_if_needed, get_auth_from_url, urldefragauth,22- select_proxy)22+ select_proxy, to_native_string)23 from .structures import CaseInsensitiveDict24 from .packages.urllib3.exceptions import ClosedPoolError25 from .packages.urllib3.exceptions import ConnectTimeoutError26 from .packages.urllib3.exceptions import HTTPError as _HTTPError127 unmodified lines154 :param proxy: The proxy to return a urllib3 ProxyManager for.155 :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.156 :returns: ProxyManager157 """158+ if proxy in self.proxy_manager:158- if not proxy in self.proxy_manager:159- if proxy.lower().startswith('socks'):160- username, password = get_auth_from_url(proxy)161- self.proxy_manager[proxy] = SOCKSProxyManager(162- proxy,163- username=username,164- password=password,165- num_pools=self._pool_connections,166- maxsize=self._pool_maxsize,167- block=self._pool_block,168- **proxy_kwargs169- )170- else:171- proxy_headers = self.proxy_headers(proxy)172- self.proxy_manager[proxy] = proxy_from_url(173- proxy,174- proxy_headers=proxy_headers,175- num_pools=self._pool_connections,176- maxsize=self._pool_maxsize,177- block=self._pool_block,178- **proxy_kwargs)159+ manager = self.proxy_manager[proxy]160+ elif proxy.lower().startswith('socks'):161+ username, password = get_auth_from_url(proxy)162+ manager = self.proxy_manager[proxy] = SOCKSProxyManager(163+ proxy,164+ username=username,165+ password=password,166+ num_pools=self._pool_connections,167+ maxsize=self._pool_maxsize,168+ block=self._pool_block,169+ **proxy_kwargs170+ )171+ else:172+ proxy_headers = self.proxy_headers(proxy)173+ manager = self.proxy_manager[proxy] = proxy_from_url(174+ proxy,175+ proxy_headers=proxy_headers,176+ num_pools=self._pool_connections,177+ maxsize=self._pool_maxsize,178+ block=self._pool_block,179+ **proxy_kwargs)180 180- return self.proxy_manager[proxy]181+ return manager182 183 def cert_verify(self, conn, url, verify, cert):184 """Verify a SSL certificate. This method should not be called from user185 code, and is only exposed for use when subclassing the116 unmodified lines302 :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs.303 """304 proxy = select_proxy(request.url, proxies)305 scheme = urlparse(request.url).scheme306+ proxy_scheme = ''307 if proxy:308 proxy_scheme = urlparse(proxy).scheme309 310 if proxy and proxy_scheme.lower().startswith('socks'):169 unmodified lines