Merge branch 'main' into spdx-conform-license
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Nate Prewitt · committed by GitHub · parents 53a0562, cb7fcd7 · Browse files · 22 files·+242 added−125 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
22 files+242 added−125 removed
- tests:+60 added−5 removed
- other:+182 added−120 removed
Provenance
- Commit
9b6c62e- Tree
aa5ed3c- Author
Nate Prewitt <nate.prewitt@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
53a0562- Parent 2
cb7fcd7
22 files changed+242 added−125 removed
modified:.github/workflows/codeql-analysis.yml+7 added
12 unmodified lines131415161718192021222324252627282944 unmodified lines12 unmodified lines branches: [main] schedule: - cron: '0 23 * * 0'
permissions: contents: read
jobs: analyze: permissions: actions: read # for github/codeql-action/init to get workflow details contents: read # for actions/checkout to fetch code security-events: write # for github/codeql-action/autobuild to send a status report name: Analyze runs-on: ubuntu-latest
strategy:44 unmodified linesmodified:.github/workflows/lint.yml+8 added-4 removed
123453456789101112131415141617181920name: Lint code
on: push: pull_request:on: [push, pull_request]
permissions: contents: read
jobs: lint: runs-on: ubuntu-20.04 timeout-minutes: 10
steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v3 uses: actions/setup-python@v4 with: python-version: "3.x" - name: Run pre-commit uses: pre-commit/action@v3.0.0modified:.github/workflows/run-tests.yml+7 added-5 removed
1234567891011121314121315161715161819202119222324259 unmodified linesname: Tests
on: [push, pull_request]
permissions: contents: read
jobs: build: runs-on: ${{ matrix.os }} timeout-minutes: 10 strategy: fail-fast: false matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"] os: [ubuntu-18.04, macOS-latest, windows-latest] python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev", "pypy-3.8", "pypy-3.9"] os: [ubuntu-22.04, macOS-latest, windows-latest] include: # pypy-3.7 on Mac OS currently fails trying to compile # brotlipy. Moving pypy3 to only test linux. # pypy-3.7 on Windows and Mac OS currently fails trying to compile # cryptography. Moving pypy-3.7 to only test linux. - python-version: pypy-3.7 os: ubuntu-latest experimental: false
steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }}9 unmodified linesmodified:docs/user/advanced.rst+27 added-1 removed
992 unmodified lines993 The mount call registers a specific instance of a Transport Adapter to a994 prefix. Once mounted, any HTTP request made using that session whose URL starts995 with the given prefix will use the given Transport Adapter.996 997+.. note:: The adapter will be chosen based on a longest prefix match. Be mindful998+ prefixes such as ``http://localhost`` will also match ``http://localhost.other.com``999+ or ``http://localhost@other.com``. It's recommended to terminate full hostnames with a ``/``.1000+1001 Many of the details of implementing a Transport Adapter are beyond the scope of1002 this documentation, but take a look at the next example for a simple SSL use-1003 case. For more than that, you might look at subclassing the1004 :class:`BaseAdapter <requests.adapters.BaseAdapter>`.24 unmodified lines1029 self.poolmanager = PoolManager(1030 num_pools=connections, maxsize=maxsize,1031 block=block, ssl_version=ssl.PROTOCOL_SSLv3)1032 1033+Example: Automatic Retries1034+^^^^^^^^^^^^^^^^^^^^^^^^^^1035+1036+By default, Requests does not retry failed connections. However, it is possible1037+to implement automatic retries with a powerful array of features, including1038+backoff, within a Requests :class:`Session <requests.Session>` using the1039+`urllib3.util.Retry`_ class::1040+1041+ from urllib3.util import Retry1042+ from requests import Session1043+ from requests.adapters import HTTPAdapter1044+1045+ s = Session()1046+ retries = Retry(1047+ total=3,1048+ backoff_factor=0.1,1049+ status_forcelist=[502, 503, 504],1050+ allowed_methods={'POST'},1051+ )1052+ s.mount('https://', HTTPAdapter(max_retries=retries))1053+1054 .. _`described here`: https://kenreitz.org/essays/2012/06/14/the-future-of-python-http1055 .. _`urllib3`: https://github.com/urllib3/urllib31056+.. _`urllib3.util.Retry`: https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.Retry1057 1058 .. _blocking-or-nonblocking:1059 1060 Blocking Or Non-Blocking?19 unmodified lines1080 ---------------1081 1082 In unusual circumstances you may want to provide headers in an ordered manner. If you pass an ``OrderedDict`` to the ``headers`` keyword argument, that will provide the headers with an ordering. *However*, the ordering of the default headers used by Requests will be preferred, which means that if you override default headers in the ``headers`` keyword argument, they may appear out of order compared to other headers in that keyword argument.1083 1058-If this is problematic, users should consider setting the default headers on a :class:`Session <requests.Session>` object, by setting :attr:`Session <requests.Session.headers>` to a custom ``OrderedDict``. That ordering will always be preferred.1084+If this is problematic, users should consider setting the default headers on a :class:`Session <requests.Session>` object, by setting :attr:`Session.headers <requests.Session.headers>` to a custom ``OrderedDict``. That ordering will always be preferred.1085 1086 .. _timeouts:1087 1088 Timeouts37 unmodified linesmodified:docs/user/install.rst+1 added-1 removed
20 unmodified lines21 `always available <https://github.com/psf/requests>`_.22 23 You can either clone the public repository::24 25- $ git clone git://github.com/psf/requests.git25+ $ git clone https://github.com/psf/requests.git26 27 Or, download the `tarball <https://github.com/psf/requests/tarball/main>`_::28 29 $ curl -OL https://github.com/psf/requests/tarball/main7 unmodified linesmodified:docs/user/quickstart.rst+2 added-2 removed
175 unmodified lines176 >>> r.raw177 <urllib3.response.HTTPResponse object at 0x101194810>178 179 >>> r.raw.read(10)180- '\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'180+ b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03'181 182 In general, however, you should use a pattern like this to save what is being183 streamed to a file::184 51 unmodified lines236 dictionary of data will automatically be form-encoded when the request is made::237 238 >>> payload = {'key1': 'value1', 'key2': 'value2'}239 240- >>> r = requests.post("https://httpbin.org/post", data=payload)240+ >>> r = requests.post('https://httpbin.org/post', data=payload)241 >>> print(r.text)242 {243 ...244 "form": {327 unmodified linesmodified:requests/__init__.py+4 added-4 removed
64 unmodified lines65 66 # Check urllib3 for compatibility.67 major, minor, patch = urllib3_version # noqa: F81168 major, minor, patch = int(major), int(minor), int(patch)69- # urllib3 >= 1.21.1, <= 1.2670- assert major == 171- assert minor >= 2172- assert minor <= 2669+ # urllib3 >= 1.21.170+ assert major >= 171+ if major == 1:72+ assert minor >= 2173 74 # Check charset_normalizer for compatibility.75 if chardet_version:76 major, minor, patch = chardet_version.split(".")[:3]104 unmodified linesmodified:requests/__version__.py+3 added-3 removed
3 unmodified lines4 5 __title__ = "requests"6 __description__ = "Python HTTP for Humans."7 __url__ = "https://requests.readthedocs.io"8-__version__ = "2.28.1"9-__build__ = 0x0228018+__version__ = "2.31.0"9+__build__ = 0x02310010 __author__ = "Kenneth Reitz"11 __author_email__ = "me@kennethreitz.org"12 __license__ = "Apache-2.0"13-__copyright__ = "Copyright 2022 Kenneth Reitz"13+__copyright__ = "Copyright Kenneth Reitz"14 __cake__ = "\u2728 \U0001f370 \u2728"modified:requests/_internal_utils.py+4 added-2 removed
12 unmodified lines13 _VALID_HEADER_NAME_RE_STR = re.compile(r"^[^:\s][^:\r\n]*$")14 _VALID_HEADER_VALUE_RE_BYTE = re.compile(rb"^\S[^\r\n]*$|^$")15 _VALID_HEADER_VALUE_RE_STR = re.compile(r"^\S[^\r\n]*$|^$")16 17+_HEADER_VALIDATORS_STR = (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR)18+_HEADER_VALIDATORS_BYTE = (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE)19 HEADER_VALIDATORS = {18- bytes: (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE),19- str: (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR),20+ bytes: _HEADER_VALIDATORS_BYTE,21+ str: _HEADER_VALIDATORS_STR,22 }23 24 25 def to_native_string(string, encoding="ascii"):25 unmodified linesmodified:requests/adapters.py+13 added-59 removed
20 unmodified lines21 from urllib3.exceptions import ProxyError as _ProxyError22 from urllib3.exceptions import ReadTimeoutError, ResponseError23 from urllib3.exceptions import SSLError as _SSLError24 from urllib3.poolmanager import PoolManager, proxy_from_url25-from urllib3.response import HTTPResponse25 from urllib3.util import Timeout as TimeoutSauce26 from urllib3.util import parse_url27 from urllib3.util.retry import Retry28 163 unmodified lines192 self.poolmanager = PoolManager(193 num_pools=connections,194 maxsize=maxsize,195 block=block,197- strict=True,196 **pool_kwargs,197 )198 199 def proxy_manager_for(self, proxy, **proxy_kwargs):282 unmodified lines482 else:483 timeout = TimeoutSauce(connect=timeout, read=timeout)484 485 try:488- if not chunked:489- resp = conn.urlopen(490- method=request.method,491- url=url,492- body=request.body,493- headers=request.headers,494- redirect=False,495- assert_same_host=False,496- preload_content=False,497- decode_content=False,498- retries=self.max_retries,499- timeout=timeout,500- )486+ resp = conn.urlopen(487+ method=request.method,488+ url=url,489+ body=request.body,490+ headers=request.headers,491+ redirect=False,492+ assert_same_host=False,493+ preload_content=False,494+ decode_content=False,495+ retries=self.max_retries,496+ timeout=timeout,497+ chunked=chunked,498+ )499 502- # Send the request.503- else:504- if hasattr(conn, "proxy_pool"):505- conn = conn.proxy_pool506-507- low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)508-509- try:510- skip_host = "Host" in request.headers511- low_conn.putrequest(512- request.method,513- url,514- skip_accept_encoding=True,515- skip_host=skip_host,516- )517-518- for header, value in request.headers.items():519- low_conn.putheader(header, value)520-521- low_conn.endheaders()522-523- for i in request.body:524- low_conn.send(hex(len(i))[2:].encode("utf-8"))525- low_conn.send(b"\r\n")526- low_conn.send(i)527- low_conn.send(b"\r\n")528- low_conn.send(b"0\r\n\r\n")529-530- # Receive the response from the server531- r = low_conn.getresponse()532-533- resp = HTTPResponse.from_httplib(534- r,535- pool=conn,536- connection=low_conn,537- preload_content=False,538- decode_content=False,539- )540- except Exception:541- # If we hit any problems here, clean up the connection.542- # Then, raise so that we can handle the actual exception.543- low_conn.close()544- raise545-500 except (ProtocolError, OSError) as err:501 raise ConnectionError(err, request=request)502 503 except MaxRetryError as e:35 unmodified linesmodified:requests/api.py+4 added-4 removed
23 unmodified lines24 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.25 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.26 :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': file-tuple}``) for multipart encoding upload.27 ``file-tuple`` can be a 2-tuple ``('filename', fileobj)``, 3-tuple ``('filename', fileobj, 'content_type')``28- or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content-type'`` is a string28+ or a 4-tuple ``('filename', fileobj, 'content_type', custom_headers)``, where ``'content_type'`` is a string29 defining the content type of the given file and ``custom_headers`` a dict-like object containing additional headers30 to add for the file.31 :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.32 :param timeout: (optional) How many seconds to wait for the server to send data72 unmodified lines105 106 :param url: URL for the new :class:`Request` object.107 :param data: (optional) Dictionary, list of tuples, bytes, or file-like108 object to send in the body of the :class:`Request`.109- :param json: (optional) json data to send in the body of the :class:`Request`.109+ :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.110 :param \*\*kwargs: Optional arguments that ``request`` takes.111 :return: :class:`Response <Response>` object112 :rtype: requests.Response113 """6 unmodified lines120 121 :param url: URL for the new :class:`Request` object.122 :param data: (optional) Dictionary, list of tuples, bytes, or file-like123 object to send in the body of the :class:`Request`.124- :param json: (optional) json data to send in the body of the :class:`Request`.124+ :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.125 :param \*\*kwargs: Optional arguments that ``request`` takes.126 :return: :class:`Response <Response>` object127 :rtype: requests.Response128 """6 unmodified lines135 136 :param url: URL for the new :class:`Request` object.137 :param data: (optional) Dictionary, list of tuples, bytes, or file-like138 object to send in the body of the :class:`Request`.139- :param json: (optional) json data to send in the body of the :class:`Request`.139+ :param json: (optional) A JSON serializable Python object to send in the body of the :class:`Request`.140 :param \*\*kwargs: Optional arguments that ``request`` takes.141 :return: :class:`Response <Response>` object142 :rtype: requests.Response143 """14 unmodified linesmodified:requests/cookies.py+8 added-8 removed
1 """2 requests.cookies3 ~~~~~~~~~~~~~~~~4 5-Compatibility code to be able to use `cookielib.CookieJar` with requests.5+Compatibility code to be able to use `http.cookiejar.CookieJar` with requests.6 7 requests.utils imports from here, so be careful with imports.8 """9 12 unmodified lines22 23 class MockRequest:24 """Wraps a `requests.Request` to mimic a `urllib2.Request`.25 26- The code in `cookielib.CookieJar` expects this interface in order to correctly26+ The code in `http.cookiejar.CookieJar` expects this interface in order to correctly27 manage cookie policies, i.e., determine whether a cookie can be set, given the28 domains of the request and the cookie.29 30 The original request object is read-only. The client is responsible for collecting44 unmodified lines75 def get_header(self, name, default=None):76 return self._r.headers.get(name, self._new_headers.get(name, default))77 78 def add_header(self, key, val):79- """cookielib has no legitimate use for this method; add it back if you find one."""79+ """cookiejar has no legitimate use for this method; add it back if you find one."""80 raise NotImplementedError(81 "Cookie headers should be added with add_unredirected_header()"82 )83 19 unmodified lines103 class MockResponse:104 """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.105 106 ...what? Basically, expose the parsed HTTP headers from the server response107- the way `cookielib` expects to see them.107+ the way `http.cookiejar` expects to see them.108 """109 110 def __init__(self, headers):111- """Make a MockResponse for `cookielib` to read.111+ """Make a MockResponse for `cookiejar` to read.112 113 :param headers: a httplib.HTTPMessage or analogous carrying the headers114 """115 self._headers = headers7 unmodified lines123 124 def extract_cookies_to_jar(jar, request, response):125 """Extract the cookies from the response into a CookieJar.126 127- :param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)127+ :param jar: http.cookiejar.CookieJar (not necessarily a RequestsCookieJar)128 :param request: our own requests.Request object129 :param response: urllib3.HTTPResponse object130 """131 if not (hasattr(response, "_original_response") and response._original_response):41 unmodified lines173 """174 175 176 class RequestsCookieJar(cookielib.CookieJar, MutableMapping):177- """Compatibility class; is a cookielib.CookieJar, but exposes a dict177+ """Compatibility class; is a http.cookiejar.CookieJar, but exposes a dict178 interface.179 180 This is the CookieJar we create by default for requests and sessions that181 don't specify one, since some clients may expect response.cookies and158 unmodified lines340 """341 self.set(name, value)342 343 def __delitem__(self, name):344- """Deletes a cookie given a name. Wraps ``cookielib.CookieJar``'s344+ """Deletes a cookie given a name. Wraps ``http.cookiejar.CookieJar``'s345 ``remove_cookie_by_name()``.346 """347 remove_cookie_by_name(self, name)348 213 unmodified linesmodified:requests/sessions.py+5 added-1 removed
322 unmodified lines323 username, password = get_auth_from_url(new_proxies[scheme])324 except KeyError:325 username, password = None, None326 327- if username and password:327+ # urllib3 handles proxy authorization for us in the standard adapter.328+ # Avoid appending this to TLS tunneled requests where it may be leaked.329+ if not scheme.startswith("https") and username and password:330 headers["Proxy-Authorization"] = _basic_auth_str(username, password)331 332 return new_proxies333 210 unmodified lines544 :param allow_redirects: (optional) Set to True by default.545 :type allow_redirects: bool546 :param proxies: (optional) Dictionary mapping protocol or protocol and547 hostname to the URL of the proxy.548+ :param hooks: (optional) Dictionary mapping hook name to one event or549+ list of events, event must be callable.550 :param stream: (optional) whether to immediately download the response551 content. Defaults to ``False``.552 :param verify: (optional) Either a boolean, in which case it controls whether we verify553 the server's TLS certificate, or a string, in which case it must be a path282 unmodified linesmodified:requests/utils.py+20 added-16 removed
23 unmodified lines24 from . import certs25 from .__version__ import __version__26 27 # to_native_string is unused here, but imported here for backwards compatibility28-from ._internal_utils import HEADER_VALIDATORS, to_native_string # noqa: F40128+from ._internal_utils import ( # noqa: F40129+ _HEADER_VALIDATORS_BYTE,30+ _HEADER_VALIDATORS_STR,31+ HEADER_VALIDATORS,32+ to_native_string,33+)34 from .compat import (35 Mapping,36 basestring,37 bytes,427 unmodified lines465 :param cj: CookieJar object to extract cookies from.466 :rtype: dict467 """468 464- cookie_dict = {}465-466- for cookie in cj:467- cookie_dict[cookie.name] = cookie.value468-469+ cookie_dict = {cookie.name: cookie.value for cookie in cj}470 return cookie_dict471 472 473 def add_dict_to_cookiejar(cj, cookie_dict):557 unmodified lines1031 1032 :param header: tuple, in the format (name, value).1033 """1034 name, value = header1035+ _validate_header_part(header, name, 0)1036+ _validate_header_part(header, value, 1)1037 1035- for part in header:1036- if type(part) not in HEADER_VALIDATORS:1037- raise InvalidHeader(1038- f"Header part ({part!r}) from {{{name!r}: {value!r}}} must be "1039- f"of type str or bytes, not {type(part)}"1040- )1038 1042- _validate_header_part(name, "name", HEADER_VALIDATORS[type(name)][0])1043- _validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1])1039+def _validate_header_part(header, header_part, header_validator_index):1040+ if isinstance(header_part, str):1041+ validator = _HEADER_VALIDATORS_STR[header_validator_index]1042+ elif isinstance(header_part, bytes):1043+ validator = _HEADER_VALIDATORS_BYTE[header_validator_index]1044+ else:1045+ raise InvalidHeader(1046+ f"Header part ({header_part!r}) from {header} "1047+ f"must be of type str or bytes, not {type(header_part)}"1048+ )1049 1045-1046-def _validate_header_part(header_part, header_kind, validator):1050 if not validator.match(header_part):1051+ header_kind = "name" if header_validator_index == 0 else "value"1052 raise InvalidHeader(1053 f"Invalid leading whitespace, reserved character(s), or return"1054 f"character(s) in header {header_kind}: {header_part!r}"1055 )35 unmodified linesmodified:tests/__init__.py+9 added-5 removed
1 """Requests test package initialisation."""2 3 import warnings4 5+try:5-from urllib3.exceptions import SNIMissingWarning6+ from urllib3.exceptions import SNIMissingWarning7 7-# urllib3 sets SNIMissingWarning to only go off once,8-# while this test suite requires it to always fire9-# so that it occurs during test_requests.test_https_warnings10-warnings.simplefilter("always", SNIMissingWarning)8+ # urllib3 1.x sets SNIMissingWarning to only go off once,9+ # while this test suite requires it to always fire10+ # so that it occurs during test_requests.test_https_warnings11+ warnings.simplefilter("always", SNIMissingWarning)12+except ImportError:13+ # urllib3 2.0 removed that warning and errors out instead14+ SNIMissingWarning = Nonemodified:tests/test_requests.py+51 added
46 unmodified lines47 from requests.models import PreparedRequest, urlencode48 from requests.sessions import SessionRedirectMixin49 from requests.structures import CaseInsensitiveDict50 51+from . import SNIMissingWarning52 from .compat import StringIO53 from .utils import override_environ54 55 # Requests to this URL should always fail with a connection timeout (nothing590 unmodified lines646 sent_headers = resp.json().get("headers", {})647 648 assert sent_headers.get("Proxy-Authorization") == proxy_auth_value649 650+ @pytest.mark.parametrize(651+ "url,has_proxy_auth",652+ (653+ ("http://example.com", True),654+ ("https://example.com", False),655+ ),656+ )657+ def test_proxy_authorization_not_appended_to_https_request(658+ self, url, has_proxy_auth659+ ):660+ session = requests.Session()661+ proxies = {662+ "http": "http://test:pass@localhost:8080",663+ "https": "http://test:pass@localhost:8090",664+ }665+ req = requests.Request("GET", url)666+ prep = req.prepare()667+ session.rebuild_proxies(prep, proxies)668+669+ assert ("Proxy-Authorization" in prep.headers) is has_proxy_auth670+671 def test_basicauth_with_netrc(self, httpbin):672 auth = ("user", "pass")673 wrong_auth = ("wronguser", "wrongpass")674 url = httpbin("basic-auth", "user", "pass")320 unmodified lines995 def test_http_with_certificate(self, httpbin):996 r = requests.get(httpbin(), cert=".")997 assert r.status_code == 200998 999+ @pytest.mark.skipif(1000+ SNIMissingWarning is None,1001+ reason="urllib3 2.0 removed that warning and errors out instead",1002+ )1003 def test_https_warnings(self, nosan_server):1004 """warnings are emitted with requests.get"""1005 host, port, ca_bundle = nosan_server1006 if HAS_MODERN_SSL or HAS_PYOPENSSL:765 unmodified lines1772 """1773 with pytest.raises(InvalidHeader):1774 requests.get(httpbin("get"), headers=invalid_header)1775 1776+ def test_header_with_subclass_types(self, httpbin):1777+ """If the subclasses does not behave *exactly* like1778+ the base bytes/str classes, this is not supported.1779+ This test is for backwards compatibility.1780+ """1781+1782+ class MyString(str):1783+ pass1784+1785+ class MyBytes(bytes):1786+ pass1787+1788+ r_str = requests.get(httpbin("get"), headers={MyString("x-custom"): "myheader"})1789+ assert r_str.request.headers["x-custom"] == "myheader"1790+1791+ r_bytes = requests.get(1792+ httpbin("get"), headers={MyBytes(b"x-custom"): b"myheader"}1793+ )1794+ assert r_bytes.request.headers["x-custom"] == b"myheader"1795+1796+ r_mixed = requests.get(1797+ httpbin("get"), headers={MyString("x-custom"): MyBytes(b"myheader")}1798+ )1799+ assert r_mixed.request.headers["x-custom"] == b"myheader"1800+1801 @pytest.mark.parametrize("files", ("foo", b"foo", bytearray(b"foo")))1802 def test_can_send_objects_with_files(self, httpbin, files):1803 data = {"a": "this is a string"}1804 files = {"b": files}1007 unmodified linesmodified:.pre-commit-config.yaml+3 added-3 removed
7 unmodified lines8 - id: debug-statements9 - id: end-of-file-fixer10 - id: trailing-whitespace11 - repo: https://github.com/PyCQA/isort12- rev: 5.10.112+ rev: 5.12.013 hooks:14 - id: isort15 - repo: https://github.com/psf/black16 rev: 22.3.04 unmodified lines21 rev: v2.31.122 hooks:23 - id: pyupgrade24 args: [--py37-plus]25-- repo: https://gitlab.com/pycqa/flake826- rev: 4.0.125+- repo: https://github.com/PyCQA/flake826+ rev: 6.0.027 hooks:28 - id: flake8modified:HISTORY.md+59 added-1 removed
4 unmodified lines5 ---6 7 - \[Short description of non-trivial change.\]8 9+2.31.0 (2023-05-22)10+-------------------11 12+**Security**13+- Versions of Requests between v2.3.0 and v2.30.0 are vulnerable to potential14+ forwarding of `Proxy-Authorization` headers to destination servers when15+ following HTTPS redirects.16+17+ When proxies are defined with user info (https://user:pass@proxy:8080), Requests18+ will construct a `Proxy-Authorization` header that is attached to the request to19+ authenticate with the proxy.20+21+ In cases where Requests receives a redirect response, it previously reattached22+ the `Proxy-Authorization` header incorrectly, resulting in the value being23+ sent through the tunneled connection to the destination server. Users who rely on24+ defining their proxy credentials in the URL are *strongly* encouraged to upgrade25+ to Requests 2.31.0+ to prevent unintentional leakage and rotate their proxy26+ credentials once the change has been fully deployed.27+28+ Users who do not use a proxy or do not supply their proxy credentials through29+ the user information portion of their proxy URL are not subject to this30+ vulnerability.31+32+ Full details can be read in our [Github Security Advisory](https://github.com/psf/requests/security/advisories/GHSA-j8r2-6x86-q33q)33+ and [CVE-2023-32681](https://nvd.nist.gov/vuln/detail/CVE-2023-32681).34+35+36+2.30.0 (2023-05-03)37+-------------------38+39+**Dependencies**40+- ⚠️ Added support for urllib3 2.0. ⚠️41+42+ This may contain minor breaking changes so we advise careful testing and43+ reviewing https://urllib3.readthedocs.io/en/latest/v2-migration-guide.html44+ prior to upgrading.45+46+ Users who wish to stay on urllib3 1.x can pin to `urllib3<2`.47+48+2.29.0 (2023-04-26)49+-------------------50+51+**Improvements**52+53+- Requests now defers chunked requests to the urllib3 implementation to improve54+ standardization. (#6226)55+- Requests relaxes header component requirements to support bytes/str subclasses. (#6356)56+57+2.28.2 (2023-01-12)58+-------------------59+60+**Dependencies**61+62+- Requests now supports charset\_normalizer 3.x. (#6261)63+64+**Bugfixes**65+66+- Updated MissingSchema exception to suggest https scheme rather than http. (#6188)67+68 2.28.1 (2022-06-29)69 -------------------70 71 **Improvements**27 unmodified lines99 - Fixed bug where setting `CURL_CA_BUNDLE` to an empty string would disable100 cert verification. All Requests 2.x versions before 2.28.0 are affected. (#6074)101 - Fixed urllib3 exception leak, wrapping `urllib3.exceptions.SSLError` with102 `requests.exceptions.SSLError` for `content` and `iter_content`. (#6057)45-- Fixed issue where invalid Windows registry entires caused proxy resolution103+- Fixed issue where invalid Windows registry entries caused proxy resolution104 to raise an exception rather than ignoring the entry. (#6149)105 - Fixed issue where entire payload could be included in the error message for106 JSONDecodeError. (#6036)107 1799 unmodified linesmodified:pyproject.toml+1 added-1 removed
2 unmodified lines3 src_paths = ["requests", "test"]4 honor_noqa = true5 6 [tool.pytest.ini_options]7-addopts = "-p no:warnings --doctest-modules"7+addopts = "--doctest-modules"8 doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS"9 minversion = "6.2"10 testpaths = [11 "requests",2 unmodified linesmodified:requirements-dev.txt+2 added-1 removed
1 -e .[socks]2 pytest>=2.8.0,<=6.2.53 pytest-cov4-pytest-httpbin==1.0.04+pytest-httpbin==2.0.05 pytest-mock==2.0.06 httpbin==0.7.07 trustme8 wheel9+cryptography<40.0.0; python_version <= '3.7' and platform_python_implementation == 'PyPy'10 11 # Flask Stack12 Flask>1.0,<2.013 markupsafe<2.1modified:setup.py+3 added-3 removed
59 unmodified lines60 61 requires = [62 "charset_normalizer>=2,<4",63 "idna>=2.5,<4",64- "urllib3>=1.21.1,<1.27",64+ "urllib3>=1.21.1,<3",65 "certifi>=2017.4.17",66 ]67 test_requirements = [68- "pytest-httpbin==0.0.7",68+ "pytest-httpbin==2.0.0",69 "pytest-cov",70 "pytest-mock",71 "pytest-xdist",72 "PySocks>=1.5.6, !=1.5.7",20 unmodified lines93 packages=["requests"],94 package_data={"": ["LICENSE", "NOTICE"]},95 package_dir={"requests": "requests"},96 include_package_data=True,97- python_requires=">=3.7, <4",97+ python_requires=">=3.7",98 install_requires=requires,99 license=about["__license__"],100 zip_safe=False,101 classifiers=[31 unmodified linesmodified:tox.ini+1 added-1 removed
1 [tox]2-envlist = py{37,38,39,310}-{default, use_chardet_on_py3}2+envlist = py{37,38,39,310,311}-{default, use_chardet_on_py3}3 4 [testenv]5 deps = -rrequirements-dev.txt6 extras =12 unmodified lines