Skip to content

Commit 9b6c62e

Browse files
authored
Merge branch 'main' into spdx-conform-license
2 parents 53a0562 + cb7fcd7 commit 9b6c62e

22 files changed

Lines changed: 242 additions & 125 deletions

.github/workflows/codeql-analysis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ on:
1414
schedule:
1515
- cron: '0 23 * * 0'
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
analyze:
22+
permissions:
23+
actions: read # for github/codeql-action/init to get workflow details
24+
contents: read # for actions/checkout to fetch code
25+
security-events: write # for github/codeql-action/autobuild to send a status report
1926
name: Analyze
2027
runs-on: ubuntu-latest
2128

.github/workflows/lint.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
name: Lint code
22

3-
on:
4-
push:
5-
pull_request:
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
67

78
jobs:
89
lint:
910
runs-on: ubuntu-20.04
11+
timeout-minutes: 10
1012

1113
steps:
1214
- uses: actions/checkout@v3
1315
- name: Set up Python
14-
uses: actions/setup-python@v3
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.x"
1519
- name: Run pre-commit
1620
uses: pre-commit/action@v3.0.0

.github/workflows/run-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ name: Tests
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
build:
710
runs-on: ${{ matrix.os }}
811
timeout-minutes: 10
912
strategy:
1013
fail-fast: false
1114
matrix:
12-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
13-
os: [ubuntu-18.04, macOS-latest, windows-latest]
15+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev", "pypy-3.8", "pypy-3.9"]
16+
os: [ubuntu-22.04, macOS-latest, windows-latest]
1417
include:
15-
# pypy-3.7 on Mac OS currently fails trying to compile
16-
# brotlipy. Moving pypy3 to only test linux.
18+
# pypy-3.7 on Windows and Mac OS currently fails trying to compile
19+
# cryptography. Moving pypy-3.7 to only test linux.
1720
- python-version: pypy-3.7
1821
os: ubuntu-latest
19-
experimental: false
2022

2123
steps:
2224
- uses: actions/checkout@v2

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: end-of-file-fixer
1010
- id: trailing-whitespace
1111
- repo: https://github.com/PyCQA/isort
12-
rev: 5.10.1
12+
rev: 5.12.0
1313
hooks:
1414
- id: isort
1515
- repo: https://github.com/psf/black
@@ -22,7 +22,7 @@ repos:
2222
hooks:
2323
- id: pyupgrade
2424
args: [--py37-plus]
25-
- repo: https://gitlab.com/pycqa/flake8
26-
rev: 4.0.1
25+
- repo: https://github.com/PyCQA/flake8
26+
rev: 6.0.0
2727
hooks:
2828
- id: flake8

HISTORY.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,64 @@ dev
66

77
- \[Short description of non-trivial change.\]
88

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 potential
14+
forwarding of `Proxy-Authorization` headers to destination servers when
15+
following HTTPS redirects.
16+
17+
When proxies are defined with user info (https://user:pass@proxy:8080), Requests
18+
will construct a `Proxy-Authorization` header that is attached to the request to
19+
authenticate with the proxy.
20+
21+
In cases where Requests receives a redirect response, it previously reattached
22+
the `Proxy-Authorization` header incorrectly, resulting in the value being
23+
sent through the tunneled connection to the destination server. Users who rely on
24+
defining their proxy credentials in the URL are *strongly* encouraged to upgrade
25+
to Requests 2.31.0+ to prevent unintentional leakage and rotate their proxy
26+
credentials once the change has been fully deployed.
27+
28+
Users who do not use a proxy or do not supply their proxy credentials through
29+
the user information portion of their proxy URL are not subject to this
30+
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 and
43+
reviewing https://urllib3.readthedocs.io/en/latest/v2-migration-guide.html
44+
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 improve
54+
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)
967

1068
2.28.1 (2022-06-29)
1169
-------------------
@@ -42,7 +100,7 @@ dev
42100
cert verification. All Requests 2.x versions before 2.28.0 are affected. (#6074)
43101
- Fixed urllib3 exception leak, wrapping `urllib3.exceptions.SSLError` with
44102
`requests.exceptions.SSLError` for `content` and `iter_content`. (#6057)
45-
- Fixed issue where invalid Windows registry entires caused proxy resolution
103+
- Fixed issue where invalid Windows registry entries caused proxy resolution
46104
to raise an exception rather than ignoring the entry. (#6149)
47105
- Fixed issue where entire payload could be included in the error message for
48106
JSONDecodeError. (#6036)

docs/user/advanced.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,10 @@ The mount call registers a specific instance of a Transport Adapter to a
994994
prefix. Once mounted, any HTTP request made using that session whose URL starts
995995
with the given prefix will use the given Transport Adapter.
996996

997+
.. note:: The adapter will be chosen based on a longest prefix match. Be mindful
998+
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+
9971001
Many of the details of implementing a Transport Adapter are beyond the scope of
9981002
this documentation, but take a look at the next example for a simple SSL use-
9991003
case. For more than that, you might look at subclassing the
@@ -1026,8 +1030,30 @@ library to use SSLv3::
10261030
num_pools=connections, maxsize=maxsize,
10271031
block=block, ssl_version=ssl.PROTOCOL_SSLv3)
10281032

1033+
Example: Automatic Retries
1034+
^^^^^^^^^^^^^^^^^^^^^^^^^^
1035+
1036+
By default, Requests does not retry failed connections. However, it is possible
1037+
to implement automatic retries with a powerful array of features, including
1038+
backoff, within a Requests :class:`Session <requests.Session>` using the
1039+
`urllib3.util.Retry`_ class::
1040+
1041+
from urllib3.util import Retry
1042+
from requests import Session
1043+
from requests.adapters import HTTPAdapter
1044+
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+
10291054
.. _`described here`: https://kenreitz.org/essays/2012/06/14/the-future-of-python-http
10301055
.. _`urllib3`: https://github.com/urllib3/urllib3
1056+
.. _`urllib3.util.Retry`: https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.Retry
10311057

10321058
.. _blocking-or-nonblocking:
10331059

@@ -1055,7 +1081,7 @@ Header Ordering
10551081

10561082
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.
10571083

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.
10591085

10601086
.. _timeouts:
10611087

docs/user/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Requests is actively developed on GitHub, where the code is
2222

2323
You can either clone the public repository::
2424

25-
$ git clone git://github.com/psf/requests.git
25+
$ git clone https://github.com/psf/requests.git
2626

2727
Or, download the `tarball <https://github.com/psf/requests/tarball/main>`_::
2828

docs/user/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ server, you can access ``r.raw``. If you want to do this, make sure you set
177177
<urllib3.response.HTTPResponse object at 0x101194810>
178178

179179
>>> 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'
181181

182182
In general, however, you should use a pattern like this to save what is being
183183
streamed to a file::
@@ -237,7 +237,7 @@ dictionary of data will automatically be form-encoded when the request is made::
237237

238238
>>> payload = {'key1': 'value1', 'key2': 'value2'}
239239

240-
>>> r = requests.post("https://httpbin.org/post", data=payload)
240+
>>> r = requests.post('https://httpbin.org/post', data=payload)
241241
>>> print(r.text)
242242
{
243243
...

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ src_paths = ["requests", "test"]
44
honor_noqa = true
55

66
[tool.pytest.ini_options]
7-
addopts = "-p no:warnings --doctest-modules"
7+
addopts = "--doctest-modules"
88
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS"
99
minversion = "6.2"
1010
testpaths = [

requests/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def check_compatibility(urllib3_version, chardet_version, charset_normalizer_ver
6666
# Check urllib3 for compatibility.
6767
major, minor, patch = urllib3_version # noqa: F811
6868
major, minor, patch = int(major), int(minor), int(patch)
69-
# urllib3 >= 1.21.1, <= 1.26
70-
assert major == 1
71-
assert minor >= 21
72-
assert minor <= 26
69+
# urllib3 >= 1.21.1
70+
assert major >= 1
71+
if major == 1:
72+
assert minor >= 21
7373

7474
# Check charset_normalizer for compatibility.
7575
if chardet_version:

0 commit comments

Comments
 (0)