From ea2b639d31270003855552a9f0c3617d7878ffd9 Mon Sep 17 00:00:00 2001 From: Gavrie Philipson Date: Mon, 29 Jul 2013 11:28:46 +0300 Subject: [PATCH] Update urllib3 to d89d508 --- requests/packages/urllib3/connectionpool.py | 14 +++++++------- requests/packages/urllib3/poolmanager.py | 6 +++--- requests/packages/urllib3/response.py | 8 +++++--- requests/packages/urllib3/util.py | 7 +++++++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/requests/packages/urllib3/connectionpool.py b/requests/packages/urllib3/connectionpool.py index 3d7d166..030eae8 100644 --- a/requests/packages/urllib3/connectionpool.py +++ b/requests/packages/urllib3/connectionpool.py @@ -26,7 +26,10 @@ except ImportError: try: # Compiled with SSL? HTTPSConnection = object - BaseSSLError = None + + class BaseSSLError(BaseException): + pass + ssl = None try: # Python 3 @@ -152,8 +155,8 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods): :class:`httplib.HTTPConnection`. :param timeout: - Socket timeout for each individual connection, can be a float. None - disables timeout. + Socket timeout in seconds for each individual connection, can be + a float. None disables timeout. :param maxsize: Number of connections to save that can be reused. More than 1 is useful @@ -376,6 +379,7 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods): :param timeout: If specified, overrides the default timeout for this one request. + It may be a float (in seconds). :param pool_timeout: If set and the pool is set to block=True, then this method will @@ -410,10 +414,6 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods): # Check host if assert_same_host and not self.is_same_host(url): - host = "%s://%s" % (self.scheme, self.host) - if self.port: - host = "%s:%d" % (host, self.port) - raise HostChangedError(self, url, retries - 1) conn = None diff --git a/requests/packages/urllib3/poolmanager.py b/requests/packages/urllib3/poolmanager.py index 804f2b2..66ceb1b 100644 --- a/requests/packages/urllib3/poolmanager.py +++ b/requests/packages/urllib3/poolmanager.py @@ -181,9 +181,9 @@ class ProxyManager(RequestMethods): """ headers_ = {'Accept': '*/*'} - host = parse_url(url).host - if host: - headers_['Host'] = host + netloc = parse_url(url).netloc + if netloc: + headers_['Host'] = netloc if headers: headers_.update(headers) diff --git a/requests/packages/urllib3/response.py b/requests/packages/urllib3/response.py index 74a5156..007a5ab 100644 --- a/requests/packages/urllib3/response.py +++ b/requests/packages/urllib3/response.py @@ -185,9 +185,11 @@ class HTTPResponse(io.IOBase): try: if decode_content and self._decoder: data = self._decoder.decompress(data) - except (IOError, zlib.error): - raise DecodeError("Received response with content-encoding: %s, but " - "failed to decode it." % content_encoding) + except (IOError, zlib.error) as e: + raise DecodeError( + "Received response with content-encoding: %s, but " + "failed to decode it." % content_encoding, + e) if flush_decoder and self._decoder: buf = self._decoder.decompress(binary_type()) diff --git a/requests/packages/urllib3/util.py b/requests/packages/urllib3/util.py index a9d30e0..39bceab 100644 --- a/requests/packages/urllib3/util.py +++ b/requests/packages/urllib3/util.py @@ -60,6 +60,13 @@ class Url(namedtuple('Url', ['scheme', 'auth', 'host', 'port', 'path', 'query', return uri + @property + def netloc(self): + """Network location including host and port""" + if self.port: + return '%s:%d' % (self.host, self.port) + return self.host + def split_first(s, delims): """ -- 2.7.4