Skip to content

Commit

Permalink
Merge pull request psf#1500 from gavrie/master
Browse files Browse the repository at this point in the history
Update urllib3 to d89d508
  • Loading branch information
Kenneth Reitz committed Aug 1, 2013
2 parents d5fd3d3 + ea2b639 commit 22701d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
14 changes: 7 additions & 7 deletions requests/packages/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@

try: # Compiled with SSL?
HTTPSConnection = object
BaseSSLError = None

class BaseSSLError(BaseException):
pass

ssl = None

try: # Python 3
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -376,6 +379,7 @@ def urlopen(self, method, url, body=None, headers=None, retries=3,
: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
Expand Down Expand Up @@ -410,10 +414,6 @@ def urlopen(self, method, url, body=None, headers=None, retries=3,

# 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
Expand Down
6 changes: 3 additions & 3 deletions requests/packages/urllib3/poolmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def _set_proxy_headers(self, url, headers=None):
"""
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)
Expand Down
8 changes: 5 additions & 3 deletions requests/packages/urllib3/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ def read(self, amt=None, decode_content=None, cache_content=False):
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())
Expand Down
7 changes: 7 additions & 0 deletions requests/packages/urllib3/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def request_uri(self):

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):
"""
Expand Down

0 comments on commit 22701d1

Please sign in to comment.