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 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

8 files+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.php67"""8NTLM authenticating pool, contributed by erikcederstran910Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10
107 unmodified lines
modified: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.php67"""8urllib3 - Thread-safe connection pooling and re-using.9"""10
22 unmodified lines
modified: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.php67from collections import MutableMapping, deque8910__all__ = ['RecentlyUsedContainer']
111 unmodified lines
modified: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.php67import logging8import socket910
185 unmodified lines
196197 if timeout is _Default:198 timeout = self.timeout199200201 conn.request(method, url, **httplib_request_kw)202 conn.sock.settimeout(timeout)203 httplib_response = conn.getresponse()204205206 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 lines
283284 raise HostChangedError("Connection pool with host '%s' tried to "285 "open a foreign host: %s" % (host, url))286279 # Request a connection from the queue280 conn = self._get_conn(timeout=pool_timeout)287 conn = None288289 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 '!'298299 # Import httplib's response into our own wrapper object300 response = HTTPResponse.from_httplib(httplib_response,301 pool=self,302 connection=conn,303 **response_kw)304294 # 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 = None308309 # else:310 # The connection will be put back into the pool when311 # ``response.release_conn()`` is called (implicitly by312 # ``response.read()``)313314 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 lines
324 # Connection broken, discard. It will be replaced next _get_conn().325 conn = None326327 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)331332 if not conn:333 log.warn("Retrying (%d attempts remain) after connection "334 "broken by '%r': %s" % (retries, e, url))
79 unmodified lines
414 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):419420 super(HTTPSConnectionPool, self).__init__(host, port,421 strict, timeout, maxsize,422 block, headers)
5 unmodified lines
428 def _new_conn(self):429 """430 Return a fresh HTTPSConnection.431 """432433 self.num_connections += 1434 log.info("Starting new HTTPS connection (%d): %s"435 % (self.num_connections, self.host))436
95 unmodified lines
modified: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.php67## Exceptions89class HTTPError(Exception):10 "Base exception used by this module."
25 unmodified lines
modified: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.php67import codecs8import mimetools9import mimetypes10
48 unmodified lines
modified: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.php67from ._collections import RecentlyUsedContainer8from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, get_host910
34 unmodified lines
45 Get a ConnectionPool based on the host, port, and scheme.46 """47 pool_key = (scheme, host, port)484950 # 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 lines
70 scheme, host, port = get_host(url)7172 port = port or port_by_scheme.get(scheme, 80)7367 return self.connection_from_host(host, port=port, scheme=scheme)74 return self.connection_from_host(host, port=port, scheme=scheme)7576 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 line
modified: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.php67import gzip8import logging9import zlib10
170 unmodified lines