Skip to content

Commit 31fbeeb

Browse files
authored
[v2] Update urllib3 to 2.6.3 (aws#9971)
1 parent afcbf9a commit 31fbeeb

11 files changed

Lines changed: 67 additions & 40 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "HTTP",
4+
"description": "Move 100-continue behavior to use `HTTPConnections` request interface."
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "urllib3",
4+
"description": "Update urllib3 to version 2.6.3"
5+
}

awscli/botocore/awsrequest.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,34 +66,34 @@ class AWSConnection:
6666
def __init__(self, *args, **kwargs):
6767
super().__init__(*args, **kwargs)
6868
self._original_response_cls = self.response_class
69-
# We'd ideally hook into httplib's states, but they're all
70-
# __mangled_vars so we use our own state var. This variable is set
71-
# when we receive an early response from the server. If this value is
72-
# set to True, any calls to send() are noops. This value is reset to
73-
# false every time _send_request is called. This is to workaround the
74-
# fact that py2.6 (and only py2.6) has a separate send() call for the
75-
# body in _send_request, as opposed to endheaders(), which is where the
76-
# body is sent in all versions > 2.6.
69+
# This variable is set when we receive an early response from the
70+
# server. If this value is set to True, any calls to send() are noops.
71+
# This value is reset to false every time _send_request is called.
72+
# This is to workaround changes in urllib3 2.0 which uses separate
73+
# send() calls in request() instead of delegating to endheaders(),
74+
# which is where the body is sent in CPython's HTTPConnection.
7775
self._response_received = False
7876
self._expect_header_set = False
77+
self._send_called = False
7978

8079
def close(self):
8180
super().close()
8281
# Reset all of our instance state we were tracking.
8382
self._response_received = False
8483
self._expect_header_set = False
84+
self._send_called = False
8585
self.response_class = self._original_response_cls
8686

87-
def _send_request(self, method, url, body, headers, *args, **kwargs):
87+
def request(self, method, url, body=None, headers=None, *args, **kwargs):
88+
if headers is None:
89+
headers = {}
8890
self._response_received = False
8991
if headers.get('Expect', b'') == b'100-continue':
9092
self._expect_header_set = True
9193
else:
9294
self._expect_header_set = False
9395
self.response_class = self._original_response_cls
94-
rval = super()._send_request(
95-
method, url, body, headers, *args, **kwargs
96-
)
96+
rval = super().request(method, url, body, headers, *args, **kwargs)
9797
self._expect_header_set = False
9898
return rval
9999

@@ -210,10 +210,15 @@ def _send_message_body(self, message_body):
210210

211211
def send(self, str):
212212
if self._response_received:
213-
logger.debug(
214-
"send() called, but reseponse already received. "
215-
"Not sending data."
216-
)
213+
if not self._send_called:
214+
# urllib3 2.0 chunks and calls send potentially
215+
# thousands of times inside `request` unlike the
216+
# standard library. Only log this once for sanity.
217+
logger.debug(
218+
"send() called, but response already received. "
219+
"Not sending data."
220+
)
221+
self._send_called = True
217222
return
218223
return super().send(str)
219224

awscli/botocore/httpsession.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import socket
55
import sys
66
from base64 import b64encode
7+
from concurrent.futures import CancelledError
78

89
from urllib3 import PoolManager, Timeout, proxy_from_url
910
from urllib3.exceptions import (
@@ -17,6 +18,7 @@
1718
)
1819
from urllib3.exceptions import ReadTimeoutError as URLLib3ReadTimeoutError
1920
from urllib3.exceptions import SSLError as URLLib3SSLError
21+
from urllib3.poolmanager import PoolKey
2022
from urllib3.util.retry import Retry
2123
from urllib3.util.ssl_ import (
2224
OP_NO_COMPRESSION,
@@ -28,8 +30,6 @@
2830
)
2931
from urllib3.util.url import parse_url
3032

31-
from concurrent.futures import CancelledError
32-
3333
try:
3434
from urllib3.util.ssl_ import OP_NO_TICKET, PROTOCOL_TLS_CLIENT
3535
except ImportError:
@@ -75,6 +75,15 @@
7575
DEFAULT_TIMEOUT = 60
7676
MAX_POOL_CONNECTIONS = 10
7777
DEFAULT_CA_BUNDLE = os.path.join(os.path.dirname(__file__), 'cacert.pem')
78+
BUFFER_SIZE = None
79+
if hasattr(PoolKey, 'key_blocksize'):
80+
# urllib3 2.0 implemented its own chunking logic and set
81+
# a default blocksize of 16KB. This creates a noticeable
82+
# performance bottleneck when transferring objects
83+
# larger than 100MB. Based on experiments, a blocksize
84+
# of 128KB significantly improves throughput before
85+
# getting diminishing returns.
86+
BUFFER_SIZE = 1024 * 128
7887

7988
try:
8089
from certifi import where
@@ -330,14 +339,15 @@ def _proxies_kwargs(self, **kwargs):
330339

331340
def _get_pool_manager_kwargs(self, **extra_kwargs):
332341
pool_manager_kwargs = {
333-
'strict': True,
334342
'timeout': self._timeout,
335343
'maxsize': self._max_pool_connections,
336344
'ssl_context': self._get_ssl_context(),
337345
'socket_options': self._socket_options,
338346
'cert_file': self._cert_file,
339347
'key_file': self._key_file,
340348
}
349+
if BUFFER_SIZE:
350+
pool_manager_kwargs['blocksize'] = BUFFER_SIZE
341351
pool_manager_kwargs.update(**extra_kwargs)
342352
return pool_manager_kwargs
343353

hssyoo.sh

Whitespace-only changes.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
"awscrt==0.29.1",
4444
"python-dateutil>=2.1,<=2.9.0",
4545
"jmespath>=0.7.1,<1.1.0",
46-
"urllib3>=1.25.4,<1.27",
46+
"urllib3>=1.25.4,<=2.6.3",
4747
]
4848
dynamic = ["version"]
4949

requirements/download-deps/portable-exe-lock.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ pyinstaller==6.11.1 \
100100
--hash=sha256:ddc0fddd75f07f7e423da1f0822e389a42af011f9589e0269b87e0d89aa48c1f \
101101
--hash=sha256:e21c7806e34f40181e7606926a14579f848bfb1dc52cbca7eea66eccccbfe977
102102
# via -r requirements/portable-exe-extras.txt
103-
pyinstaller-hooks-contrib==2025.10 \
104-
--hash=sha256:a1a737e5c0dccf1cf6f19a25e2efd109b9fec9ddd625f97f553dac16ee884881 \
105-
--hash=sha256:aa7a378518772846221f63a84d6306d9827299323243db890851474dfd1231a9
103+
pyinstaller-hooks-contrib==2025.11 \
104+
--hash=sha256:777e163e2942474aa41a8e6d31ac1635292d63422c3646c176d584d04d971c34 \
105+
--hash=sha256:dfe18632e06655fa88d218e0d768fd753e1886465c12a6d4bce04f1aaeec917d
106106
# via pyinstaller
107107
python-dateutil==2.9.0 \
108108
--hash=sha256:78e73e19c63f5b20ffa567001531680d939dc042bf7850431877645523c66709 \
@@ -164,9 +164,9 @@ six==1.17.0 \
164164
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
165165
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81
166166
# via python-dateutil
167-
urllib3==1.26.20 \
168-
--hash=sha256:0ed14ccfbf1c30a9072c7ca157e4319b70d65f623e91e7b32fadb2853431016e \
169-
--hash=sha256:40c2dc0c681e47eb8f90e7e27bf6ff7df2e677421fd46756da1161c39ca70d32
167+
urllib3==2.6.3 \
168+
--hash=sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed \
169+
--hash=sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4
170170
# via awscli (pyproject.toml)
171171
wcwidth==0.2.14 \
172172
--hash=sha256:4d478375d31bc5395a3c55c40ccdf3354688364cd61c4f6adacaa9215d0b3605 \

requirements/download-deps/portable-exe-win-lock.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ pyinstaller==6.11.1 \
9898
--hash=sha256:ddc0fddd75f07f7e423da1f0822e389a42af011f9589e0269b87e0d89aa48c1f \
9999
--hash=sha256:e21c7806e34f40181e7606926a14579f848bfb1dc52cbca7eea66eccccbfe977
100100
# via -r D:/a/aws-cli/aws-cli/requirements/portable-exe-extras.txt
101-
pyinstaller-hooks-contrib==2025.10 \
102-
--hash=sha256:a1a737e5c0dccf1cf6f19a25e2efd109b9fec9ddd625f97f553dac16ee884881 \
103-
--hash=sha256:aa7a378518772846221f63a84d6306d9827299323243db890851474dfd1231a9
101+
pyinstaller-hooks-contrib==2025.11 \
102+
--hash=sha256:777e163e2942474aa41a8e6d31ac1635292d63422c3646c176d584d04d971c34 \
103+
--hash=sha256:dfe18632e06655fa88d218e0d768fd753e1886465c12a6d4bce04f1aaeec917d
104104
# via pyinstaller
105105
python-dateutil==2.9.0 \
106106
--hash=sha256:78e73e19c63f5b20ffa567001531680d939dc042bf7850431877645523c66709 \
@@ -166,9 +166,9 @@ six==1.17.0 \
166166
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
167167
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81
168168
# via python-dateutil
169-
urllib3==1.26.20 \
170-
--hash=sha256:0ed14ccfbf1c30a9072c7ca157e4319b70d65f623e91e7b32fadb2853431016e \
171-
--hash=sha256:40c2dc0c681e47eb8f90e7e27bf6ff7df2e677421fd46756da1161c39ca70d32
169+
urllib3==2.6.3 \
170+
--hash=sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed \
171+
--hash=sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4
172172
# via awscli (D:/a/aws-cli/aws-cli/pyproject.toml)
173173
wcwidth==0.2.14 \
174174
--hash=sha256:4d478375d31bc5395a3c55c40ccdf3354688364cd61c4f6adacaa9215d0b3605 \

requirements/download-deps/system-sandbox-lock.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ six==1.17.0 \
126126
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
127127
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81
128128
# via python-dateutil
129-
urllib3==1.26.20 \
130-
--hash=sha256:0ed14ccfbf1c30a9072c7ca157e4319b70d65f623e91e7b32fadb2853431016e \
131-
--hash=sha256:40c2dc0c681e47eb8f90e7e27bf6ff7df2e677421fd46756da1161c39ca70d32
129+
urllib3==2.6.3 \
130+
--hash=sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed \
131+
--hash=sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4
132132
# via awscli (pyproject.toml)
133133
wcwidth==0.2.14 \
134134
--hash=sha256:4d478375d31bc5395a3c55c40ccdf3354688364cd61c4f6adacaa9215d0b3605 \

requirements/download-deps/system-sandbox-win-lock.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ six==1.17.0 \
126126
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
127127
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81
128128
# via python-dateutil
129-
urllib3==1.26.20 \
130-
--hash=sha256:0ed14ccfbf1c30a9072c7ca157e4319b70d65f623e91e7b32fadb2853431016e \
131-
--hash=sha256:40c2dc0c681e47eb8f90e7e27bf6ff7df2e677421fd46756da1161c39ca70d32
129+
urllib3==2.6.3 \
130+
--hash=sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed \
131+
--hash=sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4
132132
# via awscli (D:/a/aws-cli/aws-cli/pyproject.toml)
133133
wcwidth==0.2.14 \
134134
--hash=sha256:4d478375d31bc5395a3c55c40ccdf3354688364cd61c4f6adacaa9215d0b3605 \

0 commit comments

Comments
 (0)