Skip to content
Myr

urllib3 update

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 · parent dfe0e93 · Browse files · 3 files+31 added−12 removed
This commit

State

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

Diff stats

3 files+31 added−12 removed

  • other:+31 added−12 removed

3 files+31 added−12 removed

modified:requests/packages/urllib3/connectionpool.py+14 added-4 removed
27 unmodified lines
282930log = logging.getLogger(__name__)3132_Default = object()333435## Connection objects (extension of httplib)3637class VerifiedHTTPSConnection(HTTPSConnection):38 """
140 unmodified lines
179 # This should never happen if self.block == True180 log.warning("HttpConnectionPool is full, discarding connection: %s"181 % self.host)182181 def _make_request(self, conn, method, url, **httplib_request_kw):183 def _make_request(self, conn, method, url, timeout=_Default,184 **httplib_request_kw):185 """186 Perform a request on a given httplib connection object taken from our187 pool.188 """189 self.num_requests += 1190191 if timeout is _Default:192 timeout = self.timeout193194 conn.request(method, url, **httplib_request_kw)189 conn.sock.settimeout(self.timeout)195 conn.sock.settimeout(timeout)196 httplib_response = conn.getresponse()197198 log.debug("\"%s %s %s\" %s %s" %199 (method, url,
7 unmodified lines
207 return (url.startswith('/') or208 get_host(url) == (self.scheme, self.host, self.port))209210 def urlopen(self, method, url, body=None, headers=None, retries=3,205 redirect=True, assert_same_host=True, pool_timeout=None,206 release_conn=None, **response_kw):211 redirect=True, assert_same_host=True, timeout=_Default,212 pool_timeout=None, release_conn=None, **response_kw):213 """214 Get a connection from the pool and perform an HTTP request.215216 method
21 unmodified lines
238 If True, will make sure that the host of the pool requests is239 consistent else will raise HostChangedError. When False, you can240 use the pool on an HTTP proxy and request foreign hosts.241242 timeout243 If specified, overrides the default timeout for this one request.244245 pool_timeout246 If set and the pool is set to block=True, then this method will247 block for ``pool_timeout`` seconds and raise EmptyPoolError if no248 connection is available within the time period.
32 unmodified lines
281282 try:283 # Make the request on the httplib connection object284 httplib_response = self._make_request(conn, method, url,285 timeout=timeout,286 body=body, headers=headers)287 # Import httplib's response into our own wrapper object288 response = HTTPResponse.from_httplib(httplib_response,289 pool=self,
223 unmodified lines
modified:requests/packages/urllib3/poolmanager.py+16 added-8 removed
32 unmodified lines
3334 self.pools = RecentlyUsedContainer(num_pools)35 self.recently_used_pools = []3637 def connection_from_url(self, url):37 def connection_from_host(self, host, port=80, scheme='http'):38 """39 Similar to connectionpool.connection_from_url but doesn't pass any40 additional keywords to the ConnectionPool constructor. Additional41 keywords are taken from the PoolManager constructor.39 Get a ConnectionPool based on the host, port, and scheme.40 """43 scheme, host, port = get_host(url)41 pool_key = (scheme, host, port)4243 # If the scheme, host, or port doesn't match existing open connections,44 # open a new ConnectionPool.47 pool_key = (scheme, host, port or port_by_scheme.get(scheme, 80))4845 pool = self.pools.get(pool_key)46 if pool:47 return pool48
4 unmodified lines
53 self.pools[pool_key] = pool5455 return pool5657 def connection_from_url(self, url):58 """59 Similar to connectionpool.connection_from_url but doesn't pass any60 additional keywords to the ConnectionPool constructor. Additional61 keywords are taken from the PoolManager constructor.62 """63 scheme, host, port = get_host(url)6465 port = port or port_by_scheme.get(scheme, 80)6667 return self.connection_from_host(host, port=port, scheme=scheme)6869 def urlopen(self, method, url, **kw):62 "Same as HTTP(S)ConnectionPool.urlopen"70 "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."71 conn = self.connection_from_url(url)72 return conn.urlopen(method, url, **kw)
modified:requests/packages/urllib3/response.py+1 added
81 unmodified lines
82 if not self._pool or not self._connection:83 return8485 self._pool._put_conn(self._connection)86 self._connection = None8788 @property89 def data(self):90 # For backwords-compat with earlier urllib3 0.4 and earlier.
84 unmodified lines