diff options
Diffstat (limited to 'game')
24 files changed, 129 insertions, 75 deletions
diff --git a/game/python-extra/requests/__init__.py b/game/python-extra/requests/__init__.py index 626247c..f8f9429 100644 --- a/game/python-extra/requests/__init__.py +++ b/game/python-extra/requests/__init__.py @@ -57,18 +57,16 @@ def check_compatibility(urllib3_version, chardet_version): # Check urllib3 for compatibility. major, minor, patch = urllib3_version # noqa: F811 major, minor, patch = int(major), int(minor), int(patch) - # urllib3 >= 1.21.1, <= 1.25 + # urllib3 >= 1.21.1, <= 1.26 assert major == 1 assert minor >= 21 - assert minor <= 25 + assert minor <= 26 # Check chardet for compatibility. major, minor, patch = chardet_version.split('.')[:3] major, minor, patch = int(major), int(minor), int(patch) - # chardet >= 3.0.2, < 3.1.0 - assert major == 3 - assert minor < 1 - assert patch >= 2 + # chardet >= 3.0.2, < 5.0.0 + assert (3, 0, 2) <= (major, minor, patch) < (5, 0, 0) def _check_cryptography(cryptography_version): @@ -90,14 +88,22 @@ except (AssertionError, ValueError): "version!".format(urllib3.__version__, chardet.__version__), RequestsDependencyWarning) -# Attempt to enable urllib3's SNI support, if possible +# Attempt to enable urllib3's fallback for SNI support +# if the standard library doesn't support SNI or the +# 'ssl' library isn't available. try: - from urllib3.contrib import pyopenssl - pyopenssl.inject_into_urllib3() + try: + import ssl + except ImportError: + ssl = None + + if not getattr(ssl, "HAS_SNI", False): + from urllib3.contrib import pyopenssl + pyopenssl.inject_into_urllib3() - # Check cryptography version - from cryptography import __version__ as cryptography_version - _check_cryptography(cryptography_version) + # Check cryptography version + from cryptography import __version__ as cryptography_version + _check_cryptography(cryptography_version) except ImportError: pass diff --git a/game/python-extra/requests/__init__.pyo b/game/python-extra/requests/__init__.pyo Binary files differdeleted file mode 100644 index 05f7ae2..0000000 --- a/game/python-extra/requests/__init__.pyo +++ /dev/null diff --git a/game/python-extra/requests/__version__.py b/game/python-extra/requests/__version__.py index f98cd75..1267488 100644 --- a/game/python-extra/requests/__version__.py +++ b/game/python-extra/requests/__version__.py @@ -5,10 +5,10 @@ __title__ = 'requests' __description__ = 'Python HTTP for Humans.' __url__ = 'https://requests.readthedocs.io' -__version__ = '2.22.0' -__build__ = 0x022200 +__version__ = '2.25.1' +__build__ = 0x022501 __author__ = 'Kenneth Reitz' __author_email__ = 'me@kennethreitz.org' __license__ = 'Apache 2.0' -__copyright__ = 'Copyright 2019 Kenneth Reitz' +__copyright__ = 'Copyright 2020 Kenneth Reitz' __cake__ = u'\u2728 \U0001f370 \u2728' diff --git a/game/python-extra/requests/__version__.pyo b/game/python-extra/requests/__version__.pyo Binary files differdeleted file mode 100644 index efa1876..0000000 --- a/game/python-extra/requests/__version__.pyo +++ /dev/null diff --git a/game/python-extra/requests/_internal_utils.pyo b/game/python-extra/requests/_internal_utils.pyo Binary files differdeleted file mode 100644 index a4671dd..0000000 --- a/game/python-extra/requests/_internal_utils.pyo +++ /dev/null diff --git a/game/python-extra/requests/adapters.py b/game/python-extra/requests/adapters.py index 97ea25b..fa4d9b3 100644 --- a/game/python-extra/requests/adapters.py +++ b/game/python-extra/requests/adapters.py @@ -435,19 +435,64 @@ class HTTPAdapter(BaseAdapter): timeout = TimeoutSauce(connect=timeout, read=timeout) try: - resp = conn.urlopen( - method=request.method, - url=url, - body=request.body, - headers=request.headers, - redirect=False, - assert_same_host=False, - preload_content=False, - decode_content=False, - retries=self.max_retries, - timeout=timeout, - chunked=chunked - ) + if not chunked: + resp = conn.urlopen( + method=request.method, + url=url, + body=request.body, + headers=request.headers, + redirect=False, + assert_same_host=False, + preload_content=False, + decode_content=False, + retries=self.max_retries, + timeout=timeout + ) + + # Send the request. + else: + if hasattr(conn, 'proxy_pool'): + conn = conn.proxy_pool + + low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT) + + try: + low_conn.putrequest(request.method, + url, + skip_accept_encoding=True) + + for header, value in request.headers.items(): + low_conn.putheader(header, value) + + low_conn.endheaders() + + for i in request.body: + low_conn.send(hex(len(i))[2:].encode('utf-8')) + low_conn.send(b'\r\n') + low_conn.send(i) + low_conn.send(b'\r\n') + low_conn.send(b'0\r\n\r\n') + + # Receive the response from the server + try: + # For Python 2.7, use buffering of HTTP responses + r = low_conn.getresponse(buffering=True) + except TypeError: + # For compatibility with Python 3.3+ + r = low_conn.getresponse() + + resp = HTTPResponse.from_httplib( + r, + pool=conn, + connection=low_conn, + preload_content=False, + decode_content=False + ) + except: + # If we hit any problems here, clean up the connection. + # Then, reraise so that we can handle the actual exception. + low_conn.close() + raise except (ProtocolError, socket.error) as err: raise ConnectionError(err, request=request) diff --git a/game/python-extra/requests/adapters.pyo b/game/python-extra/requests/adapters.pyo Binary files differdeleted file mode 100644 index d079d6c..0000000 --- a/game/python-extra/requests/adapters.pyo +++ /dev/null diff --git a/game/python-extra/requests/api.pyo b/game/python-extra/requests/api.pyo Binary files differdeleted file mode 100644 index 3a77016..0000000 --- a/game/python-extra/requests/api.pyo +++ /dev/null diff --git a/game/python-extra/requests/auth.pyo b/game/python-extra/requests/auth.pyo Binary files differdeleted file mode 100644 index bcd94ef..0000000 --- a/game/python-extra/requests/auth.pyo +++ /dev/null diff --git a/game/python-extra/requests/certs.pyo b/game/python-extra/requests/certs.pyo Binary files differdeleted file mode 100644 index 4fd1e8d..0000000 --- a/game/python-extra/requests/certs.pyo +++ /dev/null diff --git a/game/python-extra/requests/compat.pyo b/game/python-extra/requests/compat.pyo Binary files differdeleted file mode 100644 index ffe824a..0000000 --- a/game/python-extra/requests/compat.pyo +++ /dev/null diff --git a/game/python-extra/requests/cookies.pyo b/game/python-extra/requests/cookies.pyo Binary files differdeleted file mode 100644 index 40c82be..0000000 --- a/game/python-extra/requests/cookies.pyo +++ /dev/null diff --git a/game/python-extra/requests/exceptions.py b/game/python-extra/requests/exceptions.py index a80cad8..0e9c820 100644 --- a/game/python-extra/requests/exceptions.py +++ b/game/python-extra/requests/exceptions.py @@ -94,11 +94,11 @@ class ChunkedEncodingError(RequestException): class ContentDecodingError(RequestException, BaseHTTPError): - """Failed to decode response content""" + """Failed to decode response content.""" class StreamConsumedError(RequestException, TypeError): - """The content for this response was already consumed""" + """The content for this response was already consumed.""" class RetryError(RequestException): @@ -106,21 +106,18 @@ class RetryError(RequestException): class UnrewindableBodyError(RequestException): - """Requests encountered an error when trying to rewind a body""" + """Requests encountered an error when trying to rewind a body.""" # Warnings class RequestsWarning(Warning): """Base warning for Requests.""" - pass class FileModeWarning(RequestsWarning, DeprecationWarning): """A file was opened in text mode, but Requests determined its binary length.""" - pass class RequestsDependencyWarning(RequestsWarning): """An imported dependency doesn't match the expected version range.""" - pass diff --git a/game/python-extra/requests/exceptions.pyo b/game/python-extra/requests/exceptions.pyo Binary files differdeleted file mode 100644 index 212e9cf..0000000 --- a/game/python-extra/requests/exceptions.pyo +++ /dev/null diff --git a/game/python-extra/requests/hooks.pyo b/game/python-extra/requests/hooks.pyo Binary files differdeleted file mode 100644 index 2011b9a..0000000 --- a/game/python-extra/requests/hooks.pyo +++ /dev/null diff --git a/game/python-extra/requests/models.py b/game/python-extra/requests/models.py index a60b5f4..ec2edc2 100644 --- a/game/python-extra/requests/models.py +++ b/game/python-extra/requests/models.py @@ -273,7 +273,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): """The fully mutable :class:`PreparedRequest <PreparedRequest>` object, containing the exact bytes that will be sent to the server. - Generated from either a :class:`Request <Request>` object or manually. + Instances are generated from a :class:`Request <Request>` object, and + should not be instantiated manually; doing so may produce undesirable + effects. Usage:: @@ -473,12 +475,12 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): not isinstance(data, (basestring, list, tuple, Mapping)) ]) - try: - length = super_len(data) - except (TypeError, AttributeError, UnsupportedOperation): - length = None - if is_stream: + try: + length = super_len(data) + except (TypeError, AttributeError, UnsupportedOperation): + length = None + body = data if getattr(body, 'tell', None) is not None: @@ -641,10 +643,6 @@ class Response(object): #: is a response. self.request = None - #: If there was an error in the processing of content, - #: then save the error that would return the same error when you re-appeal. - self._error = None - def __enter__(self): return self @@ -754,21 +752,12 @@ class Response(object): try: for chunk in self.raw.stream(chunk_size, decode_content=True): yield chunk - except ProtocolError as e: - self._error = ChunkedEncodingError(e) - + raise ChunkedEncodingError(e) except DecodeError as e: - self._error = ContentDecodingError(e) - + raise ContentDecodingError(e) except ReadTimeoutError as e: - self._error = ConnectionError(e) - - finally: - # if we had an error - throw the saved error - if self._error: - raise self._error - + raise ConnectionError(e) else: # Standard file-like object. while True: @@ -841,10 +830,6 @@ class Response(object): else: self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b'' - # if we had an error - throw the saved error - if self._error is not None: - raise self._error - self._content_consumed = True # don't need to release the connection; that's been handled by urllib3 # since we exhausted the data. @@ -873,9 +858,6 @@ class Response(object): # Fallback to auto-detected encoding. if self.encoding is None: encoding = self.apparent_encoding - # Forcefully remove BOM from UTF-8 - elif self.encoding.lower() == 'utf-8': - encoding = 'utf-8-sig' # Decode unicode from given encoding. try: @@ -936,7 +918,7 @@ class Response(object): return l def raise_for_status(self): - """Raises stored :class:`HTTPError`, if one occurred.""" + """Raises :class:`HTTPError`, if one occurred.""" http_error_msg = '' if isinstance(self.reason, bytes): diff --git a/game/python-extra/requests/models.pyo b/game/python-extra/requests/models.pyo Binary files differdeleted file mode 100644 index 7bbbb90..0000000 --- a/game/python-extra/requests/models.pyo +++ /dev/null diff --git a/game/python-extra/requests/packages.pyo b/game/python-extra/requests/packages.pyo Binary files differdeleted file mode 100644 index 400e97f..0000000 --- a/game/python-extra/requests/packages.pyo +++ /dev/null diff --git a/game/python-extra/requests/sessions.py b/game/python-extra/requests/sessions.py index cd8a8ae..45ab8a5 100644 --- a/game/python-extra/requests/sessions.py +++ b/game/python-extra/requests/sessions.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- """ -requests.session -~~~~~~~~~~~~~~~~ +requests.sessions +~~~~~~~~~~~~~~~~~ This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). @@ -355,7 +355,7 @@ class Session(SessionRedirectMixin): __attrs__ = [ 'headers', 'cookies', 'auth', 'proxies', 'hooks', 'params', 'verify', - 'cert', 'prefetch', 'adapters', 'stream', 'trust_env', + 'cert', 'adapters', 'stream', 'trust_env', 'max_redirects', ] @@ -387,6 +387,13 @@ class Session(SessionRedirectMixin): self.stream = False #: SSL Verification default. + #: Defaults to `True`, requiring requests to verify the TLS certificate at the + #: remote end. + #: If verify is set to `False`, requests will accept any TLS certificate + #: presented by the server, and will ignore hostname mismatches and/or + #: expired certificates, which will make your application vulnerable to + #: man-in-the-middle (MitM) attacks. + #: Only set this to `False` for testing. self.verify = True #: SSL client certificate default, if String, path to ssl client @@ -495,7 +502,12 @@ class Session(SessionRedirectMixin): content. Defaults to ``False``. :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path - to a CA bundle to use. Defaults to ``True``. + to a CA bundle to use. Defaults to ``True``. When set to + ``False``, requests will accept any TLS certificate presented by + the server, and will ignore hostname mismatches and/or expired + certificates, which will make your application vulnerable to + man-in-the-middle (MitM) attacks. Setting verify to ``False`` + may be useful during local development or testing. :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. :rtype: requests.Response @@ -658,11 +670,13 @@ class Session(SessionRedirectMixin): extract_cookies_to_jar(self.cookies, request, r.raw) - # Redirect resolving generator. - gen = self.resolve_redirects(r, request, **kwargs) - # Resolve redirects if allowed. - history = [resp for resp in gen] if allow_redirects else [] + if allow_redirects: + # Redirect resolving generator. + gen = self.resolve_redirects(r, request, **kwargs) + history = [resp for resp in gen] + else: + history = [] # Shuffle things around if there's history. if history: diff --git a/game/python-extra/requests/sessions.pyo b/game/python-extra/requests/sessions.pyo Binary files differdeleted file mode 100644 index 68d0c0f..0000000 --- a/game/python-extra/requests/sessions.pyo +++ /dev/null diff --git a/game/python-extra/requests/status_codes.pyo b/game/python-extra/requests/status_codes.pyo Binary files differdeleted file mode 100644 index 60cce63..0000000 --- a/game/python-extra/requests/status_codes.pyo +++ /dev/null diff --git a/game/python-extra/requests/structures.pyo b/game/python-extra/requests/structures.pyo Binary files differdeleted file mode 100644 index fe4e876..0000000 --- a/game/python-extra/requests/structures.pyo +++ /dev/null diff --git a/game/python-extra/requests/utils.py b/game/python-extra/requests/utils.py index c1700d7..db67938 100644 --- a/game/python-extra/requests/utils.py +++ b/game/python-extra/requests/utils.py @@ -169,14 +169,20 @@ def super_len(o): def get_netrc_auth(url, raise_errors=False): """Returns the Requests tuple auth for a given url from netrc.""" + netrc_file = os.environ.get('NETRC') + if netrc_file is not None: + netrc_locations = (netrc_file,) + else: + netrc_locations = ('~/{}'.format(f) for f in NETRC_FILES) + try: from netrc import netrc, NetrcParseError netrc_path = None - for f in NETRC_FILES: + for f in netrc_locations: try: - loc = os.path.expanduser('~/{}'.format(f)) + loc = os.path.expanduser(f) except KeyError: # os.path.expanduser can fail when $HOME is undefined and # getpwuid fails. See https://bugs.python.org/issue20164 & @@ -212,7 +218,7 @@ def get_netrc_auth(url, raise_errors=False): if raise_errors: raise - # AppEngine hackiness. + # App Engine hackiness. except (ImportError, AttributeError): pass @@ -497,6 +503,10 @@ def get_encoding_from_headers(headers): if 'text' in content_type: return 'ISO-8859-1' + if 'application/json' in content_type: + # Assume UTF-8 based on RFC 4627: https://www.ietf.org/rfc/rfc4627.txt since the charset was unset + return 'utf-8' + def stream_decode_response_unicode(iterator, r): """Stream decodes a iterator.""" diff --git a/game/python-extra/requests/utils.pyo b/game/python-extra/requests/utils.pyo Binary files differdeleted file mode 100644 index 538d1f6..0000000 --- a/game/python-extra/requests/utils.pyo +++ /dev/null |