Skip to content
Myr

Merge remote-tracking branch 'origin/master'

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 569b59f, 8f42369 · Browse files · 2 files+18 added−7 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+18 added−7 removed

  • other:+18 added−7 removed

2 files+18 added−7 removed

modified:requests/adapters.py+15 added-6 removed
23 unmodified lines
24from .cookies import extract_cookies_to_jar25from .exceptions import ConnectionError, Timeout, SSLError26from .auth import _basic_auth_str2728DEFAULT_POOLBLOCK = False29DEFAULT_POOLSIZE = 1030DEFAULT_RETRIES = 03132
20 unmodified lines
5354 :param pool_connections: The number of urllib3 connection pools to cache.55 :param pool_maxsize: The maximum number of connections to save in the pool.56 :param max_retries: The maximum number of retries each connection should attempt.57 :param pool_block: Whether the connection pool should block for connections.5859 Usage::6061 >>> import requests62 >>> s = requests.Session()63 >>> a = requests.adapters.HTTPAdapter()64 >>> s.mount('http://', a)65 """64 __attrs__ = ['max_retries', 'config', '_pool_connections', '_pool_maxsize']66 __attrs__ = ['max_retries', 'config', '_pool_connections', '_pool_maxsize',67 '_pool_block']6869 def __init__(self, pool_connections=DEFAULT_POOLSIZE,67 pool_maxsize=DEFAULT_POOLSIZE, max_retries=DEFAULT_RETRIES):70 pool_maxsize=DEFAULT_POOLSIZE, max_retries=DEFAULT_RETRIES,71 pool_block=DEFAULT_POOLBLOCK):72 self.max_retries = max_retries73 self.config = {}7475 super(HTTPAdapter, self).__init__()7677 self._pool_connections = pool_connections78 self._pool_maxsize = pool_maxsize79 self._pool_block = pool_block8076 self.init_poolmanager(pool_connections, pool_maxsize)81 self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)8283 def __getstate__(self):84 return dict((attr, getattr(self, attr, None)) for attr in85 self.__attrs__)
1 unmodified line
87 def __setstate__(self, state):88 for attr, value in state.items():89 setattr(self, attr, value)9086 self.init_poolmanager(self._pool_connections, self._pool_maxsize)91 self.init_poolmanager(self._pool_connections, self._pool_maxsize,92 block=self._pool_block)9388 def init_poolmanager(self, connections, maxsize):94 def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK):95 """Initializes a urllib3 PoolManager. This method should not be called96 from user code, and is only exposed for use when subclassing the97 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.9899 :param connections: The number of urllib3 connection pools to cache.100 :param maxsize: The maximum number of connections to save in the pool.101 :param block: Block when no free connections are available.102 """103 # save these values for pickling104 self._pool_connections = connections105 self._pool_maxsize = maxsize106 self._pool_block = block107100 self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize)108 self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize,109 block=block)110111 def cert_verify(self, conn, url, verify, cert):112 """Verify a SSL certificate. This method should not be called from user113 code, and is only exposed for use when subclassing the
229 unmodified lines
modified:requests/sessions.py+3 added-1 removed
109 unmodified lines
110 url = '%s:%s' % (parsed_rurl.scheme, url)111112 # Facilitate non-RFC2616-compliant 'location' headers113 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')114 # Compliant with RFC3986, we percent encode the url.115 if not urlparse(url).netloc:115 # Compliant with RFC3986, we percent encode the url.116 url = urljoin(resp.url, requote_uri(url))117 else:118 url = requote_uri(url)119120 prepared_request.url = url121122 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
391 unmodified lines