try: # Compiled with SSL?
HTTPSConnection = object
- BaseSSLError = None
+
+ class BaseSSLError(BaseException):
+ pass
+
ssl = None
try: # Python 3
: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
: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
# 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
"""
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)
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())
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):
"""