Skip to content
Myr

update urllib3

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 64da351 · Browse files · 3 files+44 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

3 files+44 added−11 removed

  • other:+44 added−11 removed

3 files+44 added−11 removed

modified:requests/packages/urllib3/__init__.py+18 added-2 removed
26 unmodified lines
272829# Set default logging handler to avoid "No handler found" warnings.30import logging31try:31try: # Python 2.7+32 from logging import NullHandler33except ImportError:34 class NullHandler(logging.Handler):35 def emit(self, record):36 pass3738logging.getLogger(__name__).addHandler(NullHandler())3940def add_stderr_logger(level=logging.DEBUG):41 """42 Helper for quickly adding a StreamHandler to the logger. Useful for43 debugging.4445 Returns the handler after adding it.46 """47 # This method needs to be in this __init__.py to get the __name__ correct48 # even if urllib3 is vendored within another package.49 logger = logging.getLogger(__name__)50 handler = logging.StreamHandler()51 handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))52 logger.addHandler(handler)53 logger.setLevel(level)54 logger.debug('Added an stderr logging handler to logger: %s' % __name__)55 return handler5657# ... Clean up.41del logging58del NullHandler
modified:requests/packages/urllib3/connectionpool.py+3 added-3 removed
262 unmodified lines
263 except TypeError: # Python 2.6 and older264 httplib_response = conn.getresponse()265266 # AppEngine doesn't have a version attr.267 http_version = getattr(conn, '_http_vsn_str', 'HTTP/?'),267 http_version = getattr(conn, '_http_vsn_str', 'HTTP/?')268 log.debug("\"%s %s %s\" %s %s" % (method, url, http_version,269 httplib_response.status,270 httplib_response.length))271
51 unmodified lines
323 :param retries:324 Number of retries to allow before raising a MaxRetryError exception.325326 :param redirect:327 Automatically handle redirects (status codes 301, 302, 303, 307),328 each redirect counts as a retry.327 If True, automatically handle redirects (status codes 301, 302,328 303, 307). Each redirect counts as a retry.329330 :param assert_same_host:331 If ``True``, will make sure that the host of the pool requests is332 consistent else will raise HostChangedError. When False, you can
193 unmodified lines
modified:requests/packages/urllib3/util.py+23 added-6 removed
108 unmodified lines
109 >>> get_host('google.com:80')110 ('http', 'google.com', 80)111 """112113 # This code is actually similar to urlparse.urlsplit, but much114 # simplified for our needs.115 port = None113 # While this code has overlap with stdlib's urlparse, it is much114 # simplified for our needs and less annoying.115 # Additionally, this imeplementations does silly things to be optimal116 # on CPython.117118 scheme = 'http'119 host = None120 port = None121122 # Scheme123 if '://' in url:124 scheme, url = url.split('://', 1)125126 # Find the earliest Authority Terminator122 # http://tools.ietf.org/html/rfc3986#section-3.2127 # (http://tools.ietf.org/html/rfc3986#section-3.2)128 url, _path = split_first(url, ['/', '?', '#'])129130 # Auth131 if '@' in url:132 _auth, url = url.split('@', 1)133134 # IPv6135 if url and url[0] == '[':136 host, url = url[1:].split(']', 1)137138 # Port139 if ':' in url:128 url, port = url.split(':', 1)140 _host, port = url.split(':', 1)141142 if not host:143 host = _host144145 if not port.isdigit():146 raise LocationParseError("Failed to parse: %s" % url)147148 port = int(port)149135 return scheme, url, port150 elif not host:151 host = url152153 return scheme, host, port154155156def is_connection_dropped(conn):157 """
25 unmodified lines