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 7875a12 · Browse files · 8 files·+69 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
8 files+69 added−9 removed
- other:+69 added−9 removed
Provenance
- Commit
c9f5614- Tree
62142f5- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
7875a12
8 files changed+69 added−9 removed
modified:requests/packages/urllib3/contrib/ntlmpool.py+6 added
1+# urllib3/contrib/ntlmpool.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 """8 NTLM authenticating pool, contributed by erikcederstran9 10 Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10107 unmodified linesmodified:requests/packages/urllib3/__init__.py+6 added
1+# urllib3/__init__.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 """8 urllib3 - Thread-safe connection pooling and re-using.9 """10 22 unmodified linesmodified:requests/packages/urllib3/_collections.py+6 added
1+# urllib3/_collections.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 from collections import MutableMapping, deque8 9 10 __all__ = ['RecentlyUsedContainer']111 unmodified linesmodified:requests/packages/urllib3/connectionpool.py+25 added-8 removed
1+# urllib3/connectionpool.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 import logging8 import socket9 10 185 unmodified lines196 197 if timeout is _Default:198 timeout = self.timeout199 200+201 conn.request(method, url, **httplib_request_kw)202 conn.sock.settimeout(timeout)203 httplib_response = conn.getresponse()204 205+206 log.debug("\"%s %s %s\" %s %s" %207 (method, url,208 conn._http_vsn_str, # pylint: disable-msg=W0212209 httplib_response.status, httplib_response.length))73 unmodified lines283 284 raise HostChangedError("Connection pool with host '%s' tried to "285 "open a foreign host: %s" % (host, url))286 279- # Request a connection from the queue280- conn = self._get_conn(timeout=pool_timeout)287+ conn = None288 289 try:290+ # Request a connection from the queue291+ # (Could raise SocketError: Bad file descriptor)292+ conn = self._get_conn(timeout=pool_timeout)293 # Make the request on the httplib connection object294 httplib_response = self._make_request(conn, method, url,295 timeout=timeout,296 body=body, headers=headers)297+ # print '!'298 299 # Import httplib's response into our own wrapper object300 response = HTTPResponse.from_httplib(httplib_response,301 pool=self,302 connection=conn,303 **response_kw)304 294- # The connection will be put back into the pool when295- # response.release_conn() is called (implicitly by response.read())305+ if release_conn:306+ # The connection will be released manually in the ``finally:``307+ response.connection = None308 309+ # else:310+ # The connection will be put back into the pool when311+ # ``response.release_conn()`` is called (implicitly by312+ # ``response.read()``)313+314 except (SocketTimeout, Empty), e:315 # Timed out either by socket or queue316 raise TimeoutError("Request timed out after %f seconds" %317 self.timeout)6 unmodified lines324 # Connection broken, discard. It will be replaced next _get_conn().325 conn = None326 327 finally:311- if release_conn:328+ if conn and release_conn:329 # Put the connection back to be reused313- response.release_conn() # Equivalent to self._put_conn(conn) but314- # tracks release state.330+ self._put_conn(conn)331 332 if not conn:333 log.warn("Retrying (%d attempts remain) after connection "334 "broken by '%r': %s" % (retries, e, url))79 unmodified lines414 def __init__(self, host, port=None,415 strict=False, timeout=None, maxsize=1,416 block=False, headers=None,417 key_file=None, cert_file=None,402- cert_reqs='CERT_NONE', ca_certs=None):418+ cert_reqs=ssl.CERT_REQUIRED, ca_certs=None):419 420 super(HTTPSConnectionPool, self).__init__(host, port,421 strict, timeout, maxsize,422 block, headers)5 unmodified lines428 def _new_conn(self):429 """430 Return a fresh HTTPSConnection.431 """432+433 self.num_connections += 1434 log.info("Starting new HTTPS connection (%d): %s"435 % (self.num_connections, self.host))436 95 unmodified linesmodified:requests/packages/urllib3/exceptions.py+6 added
1+# urllib3/exceptions.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 ## Exceptions8 9 class HTTPError(Exception):10 "Base exception used by this module."25 unmodified linesmodified:requests/packages/urllib3/filepost.py+6 added
1+# urllib3/filepost.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 import codecs8 import mimetools9 import mimetypes10 48 unmodified linesmodified:requests/packages/urllib3/poolmanager.py+8 added-1 removed
1+# urllib3/poolmanager.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 from ._collections import RecentlyUsedContainer8 from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, get_host9 10 34 unmodified lines45 Get a ConnectionPool based on the host, port, and scheme.46 """47 pool_key = (scheme, host, port)48 49+50 # If the scheme, host, or port doesn't match existing open connections,51 # open a new ConnectionPool.52 pool = self.pools.get(pool_key)53 if pool:16 unmodified lines70 scheme, host, port = get_host(url)71 72 port = port or port_by_scheme.get(scheme, 80)73 67- return self.connection_from_host(host, port=port, scheme=scheme)74+ return self.connection_from_host(host, port=port, scheme=scheme)75 76 def urlopen(self, method, url, **kw):77 "Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute."78 conn = self.connection_from_url(url)1 unmodified linemodified:requests/packages/urllib3/response.py+6 added
1+# urllib3/response.py2+# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)3+#4+# This module is part of urllib3 and is released under5+# the MIT License: http://www.opensource.org/licenses/mit-license.php6+7 import gzip8 import logging9 import zlib10 170 unmodified lines