mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-18 16:53:38 +00:00
Merge branch 'feature/UpdateRequests' into dev
This commit is contained in:
commit
b6cfffb4e3
6 changed files with 44 additions and 78 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
* Update filelock 3.9.0 (ce3e891) to 3.11.0 (d3241b9)
|
* Update filelock 3.9.0 (ce3e891) to 3.11.0 (d3241b9)
|
||||||
* Update Msgpack 1.0.4 (b5acfd5) to 1.0.5 (0516c2c)
|
* Update Msgpack 1.0.4 (b5acfd5) to 1.0.5 (0516c2c)
|
||||||
|
* Update Requests library 2.28.1 (ec553c2) to 2.29.0 (87d63de)
|
||||||
* Update SimpleJSON 3.18.1 (c891b95) to 3.19.1 (aeb63ee)
|
* Update SimpleJSON 3.18.1 (c891b95) to 3.19.1 (aeb63ee)
|
||||||
* Update Tornado Web Server 6.3.0 (7186b86) to 6.3.1 (419838b)
|
* Update Tornado Web Server 6.3.0 (7186b86) to 6.3.1 (419838b)
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
__title__ = "requests"
|
__title__ = "requests"
|
||||||
__description__ = "Python HTTP for Humans."
|
__description__ = "Python HTTP for Humans."
|
||||||
__url__ = "https://requests.readthedocs.io"
|
__url__ = "https://requests.readthedocs.io"
|
||||||
__version__ = "2.28.1"
|
__version__ = "2.29.0"
|
||||||
__build__ = 0x022801
|
__build__ = 0x022900
|
||||||
__author__ = "Kenneth Reitz"
|
__author__ = "Kenneth Reitz"
|
||||||
__author_email__ = "me@kennethreitz.org"
|
__author_email__ = "me@kennethreitz.org"
|
||||||
__license__ = "Apache 2.0"
|
__license__ = "Apache 2.0"
|
||||||
__copyright__ = "Copyright 2022 Kenneth Reitz"
|
__copyright__ = "Copyright Kenneth Reitz"
|
||||||
__cake__ = "\u2728 \U0001f370 \u2728"
|
__cake__ = "\u2728 \U0001f370 \u2728"
|
||||||
|
|
|
@ -14,9 +14,11 @@ _VALID_HEADER_NAME_RE_STR = re.compile(r"^[^:\s][^:\r\n]*$")
|
||||||
_VALID_HEADER_VALUE_RE_BYTE = re.compile(rb"^\S[^\r\n]*$|^$")
|
_VALID_HEADER_VALUE_RE_BYTE = re.compile(rb"^\S[^\r\n]*$|^$")
|
||||||
_VALID_HEADER_VALUE_RE_STR = re.compile(r"^\S[^\r\n]*$|^$")
|
_VALID_HEADER_VALUE_RE_STR = re.compile(r"^\S[^\r\n]*$|^$")
|
||||||
|
|
||||||
|
_HEADER_VALIDATORS_STR = (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR)
|
||||||
|
_HEADER_VALIDATORS_BYTE = (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE)
|
||||||
HEADER_VALIDATORS = {
|
HEADER_VALIDATORS = {
|
||||||
bytes: (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE),
|
bytes: _HEADER_VALIDATORS_BYTE,
|
||||||
str: (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR),
|
str: _HEADER_VALIDATORS_STR,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ from urllib3.exceptions import ProxyError as _ProxyError
|
||||||
from urllib3.exceptions import ReadTimeoutError, ResponseError
|
from urllib3.exceptions import ReadTimeoutError, ResponseError
|
||||||
from urllib3.exceptions import SSLError as _SSLError
|
from urllib3.exceptions import SSLError as _SSLError
|
||||||
from urllib3.poolmanager import PoolManager, proxy_from_url
|
from urllib3.poolmanager import PoolManager, proxy_from_url
|
||||||
from urllib3.response import HTTPResponse
|
|
||||||
from urllib3.util import Timeout as TimeoutSauce
|
from urllib3.util import Timeout as TimeoutSauce
|
||||||
from urllib3.util import parse_url
|
from urllib3.util import parse_url
|
||||||
from urllib3.util.retry import Retry
|
from urllib3.util.retry import Retry
|
||||||
|
@ -485,63 +484,19 @@ class HTTPAdapter(BaseAdapter):
|
||||||
timeout = TimeoutSauce(connect=timeout, read=timeout)
|
timeout = TimeoutSauce(connect=timeout, read=timeout)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not chunked:
|
resp = conn.urlopen(
|
||||||
resp = conn.urlopen(
|
method=request.method,
|
||||||
method=request.method,
|
url=url,
|
||||||
url=url,
|
body=request.body,
|
||||||
body=request.body,
|
headers=request.headers,
|
||||||
headers=request.headers,
|
redirect=False,
|
||||||
redirect=False,
|
assert_same_host=False,
|
||||||
assert_same_host=False,
|
preload_content=False,
|
||||||
preload_content=False,
|
decode_content=False,
|
||||||
decode_content=False,
|
retries=self.max_retries,
|
||||||
retries=self.max_retries,
|
timeout=timeout,
|
||||||
timeout=timeout,
|
chunked=chunked,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Send the request.
|
|
||||||
else:
|
|
||||||
if hasattr(conn, "proxy_pool"):
|
|
||||||
conn = conn.proxy_pool
|
|
||||||
|
|
||||||
low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)
|
|
||||||
|
|
||||||
try:
|
|
||||||
skip_host = "Host" in request.headers
|
|
||||||
low_conn.putrequest(
|
|
||||||
request.method,
|
|
||||||
url,
|
|
||||||
skip_accept_encoding=True,
|
|
||||||
skip_host=skip_host,
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
r = low_conn.getresponse()
|
|
||||||
|
|
||||||
resp = HTTPResponse.from_httplib(
|
|
||||||
r,
|
|
||||||
pool=conn,
|
|
||||||
connection=low_conn,
|
|
||||||
preload_content=False,
|
|
||||||
decode_content=False,
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
# If we hit any problems here, clean up the connection.
|
|
||||||
# Then, raise so that we can handle the actual exception.
|
|
||||||
low_conn.close()
|
|
||||||
raise
|
|
||||||
|
|
||||||
except (ProtocolError, OSError) as err:
|
except (ProtocolError, OSError) as err:
|
||||||
raise ConnectionError(err, request=request)
|
raise ConnectionError(err, request=request)
|
||||||
|
|
|
@ -106,7 +106,7 @@ def post(url, data=None, json=None, **kwargs):
|
||||||
:param url: URL for the new :class:`Request` object.
|
:param url: URL for the new :class:`Request` object.
|
||||||
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
object to send in the body of the :class:`Request`.
|
object to send in the body of the :class:`Request`.
|
||||||
:param json: (optional) json data to send in the body of the :class:`Request`.
|
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
|
||||||
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
:return: :class:`Response <Response>` object
|
:return: :class:`Response <Response>` object
|
||||||
:rtype: requests.Response
|
:rtype: requests.Response
|
||||||
|
@ -121,7 +121,7 @@ def put(url, data=None, **kwargs):
|
||||||
:param url: URL for the new :class:`Request` object.
|
:param url: URL for the new :class:`Request` object.
|
||||||
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
object to send in the body of the :class:`Request`.
|
object to send in the body of the :class:`Request`.
|
||||||
:param json: (optional) json data to send in the body of the :class:`Request`.
|
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
|
||||||
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
:return: :class:`Response <Response>` object
|
:return: :class:`Response <Response>` object
|
||||||
:rtype: requests.Response
|
:rtype: requests.Response
|
||||||
|
@ -136,7 +136,7 @@ def patch(url, data=None, **kwargs):
|
||||||
:param url: URL for the new :class:`Request` object.
|
:param url: URL for the new :class:`Request` object.
|
||||||
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
|
||||||
object to send in the body of the :class:`Request`.
|
object to send in the body of the :class:`Request`.
|
||||||
:param json: (optional) json data to send in the body of the :class:`Request`.
|
:param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.
|
||||||
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
:param \*\*kwargs: Optional arguments that ``request`` takes.
|
||||||
:return: :class:`Response <Response>` object
|
:return: :class:`Response <Response>` object
|
||||||
:rtype: requests.Response
|
:rtype: requests.Response
|
||||||
|
|
|
@ -25,7 +25,12 @@ from . import certs
|
||||||
from .__version__ import __version__
|
from .__version__ import __version__
|
||||||
|
|
||||||
# to_native_string is unused here, but imported here for backwards compatibility
|
# to_native_string is unused here, but imported here for backwards compatibility
|
||||||
from ._internal_utils import HEADER_VALIDATORS, to_native_string # noqa: F401
|
from ._internal_utils import ( # noqa: F401
|
||||||
|
_HEADER_VALIDATORS_BYTE,
|
||||||
|
_HEADER_VALIDATORS_STR,
|
||||||
|
HEADER_VALIDATORS,
|
||||||
|
to_native_string,
|
||||||
|
)
|
||||||
from .compat import (
|
from .compat import (
|
||||||
Mapping,
|
Mapping,
|
||||||
basestring,
|
basestring,
|
||||||
|
@ -1031,20 +1036,23 @@ def check_header_validity(header):
|
||||||
:param header: tuple, in the format (name, value).
|
:param header: tuple, in the format (name, value).
|
||||||
"""
|
"""
|
||||||
name, value = header
|
name, value = header
|
||||||
|
_validate_header_part(header, name, 0)
|
||||||
for part in header:
|
_validate_header_part(header, value, 1)
|
||||||
if type(part) not in HEADER_VALIDATORS:
|
|
||||||
raise InvalidHeader(
|
|
||||||
f"Header part ({part!r}) from {{{name!r}: {value!r}}} must be "
|
|
||||||
f"of type str or bytes, not {type(part)}"
|
|
||||||
)
|
|
||||||
|
|
||||||
_validate_header_part(name, "name", HEADER_VALIDATORS[type(name)][0])
|
|
||||||
_validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1])
|
|
||||||
|
|
||||||
|
|
||||||
def _validate_header_part(header_part, header_kind, validator):
|
def _validate_header_part(header, header_part, header_validator_index):
|
||||||
|
if isinstance(header_part, str):
|
||||||
|
validator = _HEADER_VALIDATORS_STR[header_validator_index]
|
||||||
|
elif isinstance(header_part, bytes):
|
||||||
|
validator = _HEADER_VALIDATORS_BYTE[header_validator_index]
|
||||||
|
else:
|
||||||
|
raise InvalidHeader(
|
||||||
|
f"Header part ({header_part!r}) from {header} "
|
||||||
|
f"must be of type str or bytes, not {type(header_part)}"
|
||||||
|
)
|
||||||
|
|
||||||
if not validator.match(header_part):
|
if not validator.match(header_part):
|
||||||
|
header_kind = "name" if header_validator_index == 0 else "value"
|
||||||
raise InvalidHeader(
|
raise InvalidHeader(
|
||||||
f"Invalid leading whitespace, reserved character(s), or return"
|
f"Invalid leading whitespace, reserved character(s), or return"
|
||||||
f"character(s) in header {header_kind}: {header_part!r}"
|
f"character(s) in header {header_kind}: {header_part!r}"
|
||||||
|
|
Loading…
Reference in a new issue