summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.com>2013-07-31 18:23:43 -0700
committerKenneth Reitz <me@kennethreitz.com>2013-07-31 18:23:43 -0700
commit22701d149ad9585cc01b3f9bda4e78cd77ffb996 (patch)
tree1df38b963162f52b523f9002022870b584be9ac2
parentd5fd3d33311aeec0a01c5dc72e475283d0cb53f5 (diff)
parentea2b639d31270003855552a9f0c3617d7878ffd9 (diff)
downloadpython-requests-2.0.tar.gz
Merge pull request #1500 from gavrie/master2.0
Update urllib3 to d89d508
-rw-r--r--requests/packages/urllib3/connectionpool.py14
-rw-r--r--requests/packages/urllib3/poolmanager.py6
-rw-r--r--requests/packages/urllib3/response.py8
-rw-r--r--requests/packages/urllib3/util.py7
4 files changed, 22 insertions, 13 deletions
diff --git a/requests/packages/urllib3/connectionpool.py b/requests/packages/urllib3/connectionpool.py
index 3d7d166a..030eae89 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 804f2b2f..66ceb1b4 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 74a5156c..007a5ab9 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 a9d30e01..39bceaba 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):
"""