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 5937282 · Browse files · 1 file·+30 added−9 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+30 added−9 removed
- other:+30 added−9 removed
Provenance
- Commit
8f58c09- Tree
be5ab18- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
5937282
1 file changed+30 added−9 removed
modified:requests/packages/urllib3/connectionpool.py+30 added-9 removed
208 unmodified lines209 210 if timeout is _Default:211 timeout = self.timeout212 213+ conn.timeout = timeout # This only does anything in Py26+214+215 conn.request(method, url, **httplib_request_kw)216 conn.sock.settimeout(timeout)217 httplib_response = conn.getresponse()218 26 unmodified lines245 246 More commonly, it's appropriate to use a convenience method provided247 by :class:`.RequestMethods`, such as :meth:`.request`.248 249+ .. note::250+251+ `release_conn` will only behave as expected if252+ `preload_content=False` because we want to make253+ `preload_content=False` the default behaviour someday soon without254+ breaking backwards compatibility.255+256 :param method:257 HTTP request method (such as GET, POST, PUT, etc.)258 259 :param body:27 unmodified lines287 connection is available within the time period.288 289 :param release_conn:290 If False, then the urlopen call will not release the connection282- back into the pool once a response is received. This is useful if283- you're not preloading the response's content immediately. You will284- need to call ``r.release_conn()`` on the response ``r`` to return285- the connection back into the pool. If None, it takes the value of291+ back into the pool once a response is received (but will release if292+ you read the entire contents of the response such as when293+ `preload_content=True`). This is useful if you're not preloading294+ the response's content immediately. You will need to call295+ ``r.release_conn()`` on the response ``r`` to return the connection296+ back into the pool. If None, it takes the value of297 ``response_kw.get('preload_content', True)``.298 299 :param \**response_kw:300 Additional parameters are passed to4 unmodified lines305 306 if retries < 0:307 raise MaxRetryError("Max retries exceeded for url: %s" % url)308 309+ if timeout is _Default:310+ timeout = self.timeout311+312 if release_conn is None:313 release_conn = response_kw.get('preload_content', True)314 315 # Check host33 unmodified lines349 # The connection will be put back into the pool when350 # ``response.release_conn()`` is called (implicitly by351 # ``response.read()``)352 339- except (SocketTimeout, Empty), e:340- # Timed out either by socket or queue341- raise TimeoutError("Request timed out after %s seconds" %342- self.timeout)353+ except (Empty), e:354+ # Timed out by queue355+ raise TimeoutError("Request timed out. (pool_timeout=%s)" %356+ pool_timeout)357 358+ except (SocketTimeout), e:359+ # Timed out by socket360+ raise TimeoutError("Request timed out. (timeout=%s)" %361+ timeout)362+363 except (BaseSSLError), e:364 # SSL certificate error365 raise SSLError(e)366 139 unmodified lines506 # This code is actually similar to urlparse.urlsplit, but much507 # simplified for our needs.508 port = None509 scheme = 'http'491- if '//' in url:510+ if '://' in url:511 scheme, url = url.split('://', 1)512 if '/' in url:513 url, _path = url.split('/', 1)514+ if '@' in url:515+ _auth, url = url.split('@', 1)516 if ':' in url:517 url, port = url.split(':', 1)518 port = int(port)519 return scheme, url, port27 unmodified lines