Skip to content
Myr

Upgrade urllib3 to 490d3a227fadb626cd54a240b9d0922f849914b4

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Joe Smith · committed by Joe Smith · parent a5a314e · Browse files · 5 files+79 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+79 added−11 removed

  • other:+79 added−11 removed

5 files+79 added−11 removed

modified:requests/packages/urllib3/util/ssl_.py+6 added-3 removed
1from binascii import hexlify, unhexlify2from hashlib import md5, sha12from hashlib import md5, sha1, sha25634from ..exceptions import SSLError56
88 unmodified lines
95 # Maps the length of a digest to a possible hash function producing96 # this digest.97 hashfunc_map = {98 16: md5,99 20: sha199 20: sha1,100 32: sha256,101 }102103 fingerprint = fingerprint.replace(':', '').lower()104 digest_length, odd = divmod(len(fingerprint), 2)
106 unmodified lines
211 context.set_ciphers(ciphers or _DEFAULT_CIPHERS)212213 context.verify_mode = cert_reqs214 if getattr(context, 'check_hostname', None) is not None: # Platform-specific: Python 3.2214 context.check_hostname = (context.verify_mode == ssl.CERT_REQUIRED)215 # We do our own verification, including fingerprints and alternative216 # hostnames. So disable it here217 context.check_hostname = False218 return context219220221def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
36 unmodified lines
modified:requests/packages/urllib3/_collections.py+11 added-3 removed
1from collections import Mapping, MutableMapping2try:3 from threading import RLock4except ImportError: # Platform-specific: No threads available4except ImportError: # Platform-specific: No threads available5 class RLock:6 def __enter__(self):7 pass89 def __exit__(self, exc_type, exc_value, traceback):10 pass111213try: # Python 2.7+13try: # Python 2.7+14 from collections import OrderedDict15except ImportError:16 from .packages.ordered_dict import OrderedDict17from .packages.six import iterkeys, itervalues
142 unmodified lines
160161 def getlist(self, key):162 """Returns a list of all the values for the named field. Returns an163 empty list if the key doesn't exist."""164 return self[key].split(', ') if key in self else []164 return [v for k, v in self._data.get(key.lower(), [])]165166 def copy(self):167 h = HTTPHeaderDict()168 for key in self._data:
26 unmodified lines
195 yield headers[0][0]196197 def __repr__(self):198 return '%s(%r)' % (self.__class__.__name__, dict(self.items()))199200 def update(self, *args, **kwds):201 headers = args[0]202 if isinstance(headers, HTTPHeaderDict):203 for key in iterkeys(headers._data):204 self._data.setdefault(key.lower(), []).extend(headers._data[key])205 else:206 super(HTTPHeaderDict, self).update(*args, **kwds)
modified:requests/packages/urllib3/connectionpool.py+24 added-1 removed
70 unmodified lines
71 def __str__(self):72 return '%s(host=%r, port=%r)' % (type(self).__name__,73 self.host, self.port)7475 def __enter__(self):76 return self7778 def __exit__(self, exc_type, exc_val, exc_tb):79 self.close()80 # Return False to re-raise any potential exceptions81 return False8283 def close():84 """85 Close all pooled connections and disable the pool.86 """87 pass888990# This is taken from http://hg.python.org/cpython/file/7aaba721ebc0/Lib/socket.py#l25291_blocking_errnos = set([errno.EAGAIN, errno.EWOULDBLOCK])9293
273 unmodified lines
367 conn.sock.settimeout(read_timeout)368369 # Receive the response from the server370 try:356 try: # Python 2.7+, use buffering of HTTP responses371 try: # Python 2.7, use buffering of HTTP responses372 httplib_response = conn.getresponse(buffering=True)373 except TypeError: # Python 2.6 and older374 httplib_response = conn.getresponse()375 except (SocketTimeout, BaseSSLError, SocketError) as e:
196 unmodified lines
572 conn.close()573 conn = None574 raise SSLError(e)575576 except SSLError:577 # Treat SSLError separately from BaseSSLError to preserve578 # traceback.579 if conn:580 conn.close()581 conn = None582 raise583584 except (TimeoutError, HTTPException, SocketError, ConnectionError) as e:585 if conn:586 # Discard the connection for these exceptions. It will be587 # be replaced during the next _get_conn() call.
210 unmodified lines
modified:requests/packages/urllib3/poolmanager.py+8 added
62 unmodified lines
63 self.connection_pool_kw = connection_pool_kw64 self.pools = RecentlyUsedContainer(num_pools,65 dispose_func=lambda p: p.close())6667 def __enter__(self):68 return self6970 def __exit__(self, exc_type, exc_val, exc_tb):71 self.clear()72 # Return False to re-raise any potential exceptions73 return False7475 def _new_pool(self, scheme, host, port):76 """77 Create a new :class:`ConnectionPool` based on host, port and scheme.78
195 unmodified lines
modified:requests/packages/urllib3/response.py+30 added-4 removed
1import zlib2import io3from socket import timeout as SocketTimeout45from .packages import six6from ._collections import HTTPHeaderDict7from .exceptions import ProtocolError, DecodeError, ReadTimeoutError8from .packages.six import string_types as basestring, binary_type9from .connection import HTTPException, BaseSSLError10from .util.response import is_fp_closed11121213class DeflateDecoder(object):1415 def __init__(self):16 self._first_try = True
3 unmodified lines
20 def __getattr__(self, name):21 return getattr(self._obj, name)2223 def decompress(self, data):24 if not data:25 return data2627 if not self._first_try:28 return self._obj.decompress(data)2930 self._data += data
7 unmodified lines
38 finally:39 self._data = None404142class GzipDecoder(object):4344 def __init__(self):45 self._obj = zlib.decompressobj(16 + zlib.MAX_WBITS)4647 def __getattr__(self, name):48 return getattr(self._obj, name)4950 def decompress(self, data):51 if not data:52 return data53 return self._obj.decompress(data)545556def _get_decoder(mode):57 if mode == 'gzip':41 return zlib.decompressobj(16 + zlib.MAX_WBITS)58 return GzipDecoder()5960 return DeflateDecoder()6162
155 unmodified lines
218 raise ReadTimeoutError(self._pool, None, 'Read timed out.')219220 except BaseSSLError as e:221 # FIXME: Is there a better way to differentiate between SSLErrors?205 if not 'read operation timed out' in str(e): # Defensive:222 if 'read operation timed out' not in str(e): # Defensive:223 # This shouldn't happen but just in case we're missing an edge224 # case, let's avoid swallowing SSL errors.225 raise226
59 unmodified lines
286 """287288 headers = HTTPHeaderDict()289 for k, v in r.getheaders():290 if k.lower() != 'set-cookie':273 headers.add(k, v)291 headers.add(k, v)292293 if six.PY3: # Python 3:294 cookies = r.msg.get_all('set-cookie') or tuple()295 else: # Python 2:296 cookies = r.msg.getheaders('set-cookie')297298 for cookie in cookies:299 headers.add('set-cookie', cookie)300301 # HTTPResponse objects in Python 3 don't have a .strict attribute302 strict = getattr(r, 'strict', 0)303 return ResponseCls(body=r,304 headers=headers,
55 unmodified lines