Skip to content

Commit b968548

Browse files
committed
Upgrade urllib3 to 1.26.18
1 parent b28816e commit b968548

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed

news/urllib3.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade urllib3 to 1.26.18

src/pip/_vendor/urllib3/_collections.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,24 @@ def getlist(self, key, default=__marker):
268268
else:
269269
return vals[1:]
270270

271+
def _prepare_for_method_change(self):
272+
"""
273+
Remove content-specific header fields before changing the request
274+
method to GET or HEAD according to RFC 9110, Section 15.4.
275+
"""
276+
content_specific_headers = [
277+
"Content-Encoding",
278+
"Content-Language",
279+
"Content-Location",
280+
"Content-Type",
281+
"Content-Length",
282+
"Digest",
283+
"Last-Modified",
284+
]
285+
for header in content_specific_headers:
286+
self.discard(header)
287+
return self
288+
271289
# Backwards compatibility for httplib
272290
getheaders = getlist
273291
getallmatchingheaders = getlist

src/pip/_vendor/urllib3/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file is protected via CODEOWNERS
2-
__version__ = "1.26.17"
2+
__version__ = "1.26.18"

src/pip/_vendor/urllib3/connectionpool.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from socket import error as SocketError
1010
from socket import timeout as SocketTimeout
1111

12+
from ._collections import HTTPHeaderDict
1213
from .connection import (
1314
BaseSSLError,
1415
BrokenPipeError,
@@ -843,7 +844,11 @@ def _is_ssl_error_message_from_http_proxy(ssl_error):
843844
redirect_location = redirect and response.get_redirect_location()
844845
if redirect_location:
845846
if response.status == 303:
847+
# Change the method according to RFC 9110, Section 15.4.4.
846848
method = "GET"
849+
# And lose the body not to transfer anything sensitive.
850+
body = None
851+
headers = HTTPHeaderDict(headers)._prepare_for_method_change()
847852

848853
try:
849854
retries = retries.increment(method, url, response=response, _pool=self)

src/pip/_vendor/urllib3/contrib/securetransport.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@
6464
import threading
6565
import weakref
6666

67-
from pip._vendor import six
68-
6967
from .. import util
68+
from ..packages import six
7069
from ..util.ssl_ import PROTOCOL_TLS_CLIENT
7170
from ._securetransport.bindings import CoreFoundation, Security, SecurityConst
7271
from ._securetransport.low_level import (

src/pip/_vendor/urllib3/poolmanager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import functools
55
import logging
66

7-
from ._collections import RecentlyUsedContainer
7+
from ._collections import HTTPHeaderDict, RecentlyUsedContainer
88
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme
99
from .exceptions import (
1010
LocationValueError,
@@ -382,9 +382,12 @@ def urlopen(self, method, url, redirect=True, **kw):
382382
# Support relative URLs for redirecting.
383383
redirect_location = urljoin(url, redirect_location)
384384

385-
# RFC 7231, Section 6.4.4
386385
if response.status == 303:
386+
# Change the method according to RFC 9110, Section 15.4.4.
387387
method = "GET"
388+
# And lose the body not to transfer anything sensitive.
389+
kw["body"] = None
390+
kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change()
388391

389392
retries = kw.get("retries")
390393
if not isinstance(retries, Retry):

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requests==2.31.0
1111
certifi==2023.7.22
1212
chardet==5.2.0
1313
idna==3.6
14-
urllib3==1.26.17
14+
urllib3==1.26.18
1515
rich==13.7.0
1616
pygments==2.17.2
1717
typing_extensions==4.9.0

0 commit comments

Comments
 (0)