Skip to content

Commit 484d2fe

Browse files
chore(deps): updated pip modules
1 parent 4cb50e1 commit 484d2fe

6 files changed

Lines changed: 36 additions & 10 deletions

File tree

lib/urllib3/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
commit_id: COMMIT_ID
2929
__commit_id__: COMMIT_ID
3030

31-
__version__ = version = '2.6.1'
32-
__version_tuple__ = version_tuple = (2, 6, 1)
31+
__version__ = version = '2.6.3'
32+
__version_tuple__ = version_tuple = (2, 6, 3)
3333

3434
__commit_id__ = commit_id = None

lib/urllib3/contrib/emscripten/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ def inject_into_urllib3() -> None:
1414
HTTPSConnectionPool.ConnectionCls = EmscriptenHTTPSConnection
1515
urllib3.connection.HTTPConnection = EmscriptenHTTPConnection # type: ignore[misc,assignment]
1616
urllib3.connection.HTTPSConnection = EmscriptenHTTPSConnection # type: ignore[misc,assignment]
17+
urllib3.connection.VerifiedHTTPSConnection = EmscriptenHTTPSConnection # type: ignore[assignment]

lib/urllib3/contrib/emscripten/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class EmscriptenHTTPConnection:
4040
is_verified: bool = False
4141
proxy_is_verified: bool | None = None
4242

43+
response_class: type[BaseHTTPResponse] = EmscriptenHttpResponseWrapper
4344
_response: EmscriptenResponse | None
4445

4546
def __init__(

lib/urllib3/http2/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import types
77
import typing
88

9-
import h2.config # type: ignore[import-untyped]
10-
import h2.connection # type: ignore[import-untyped]
11-
import h2.events # type: ignore[import-untyped]
9+
import h2.config
10+
import h2.connection
11+
import h2.events
1212

1313
from .._base_connection import _TYPE_BODY
1414
from .._collections import HTTPHeaderDict

lib/urllib3/response.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,11 @@ def drain_conn(self) -> None:
797797
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
798798
"""
799799
try:
800-
self.read()
800+
self.read(
801+
# Do not spend resources decoding the content unless
802+
# decoding has already been initiated.
803+
decode_content=self._has_decoded_content,
804+
)
801805
except (HTTPError, OSError, BaseSSLError, HTTPException):
802806
pass
803807

@@ -1407,10 +1411,14 @@ def read_chunked(
14071411
amt = None
14081412

14091413
while True:
1410-
self._update_chunk_length()
1411-
if self.chunk_left == 0:
1412-
break
1413-
chunk = self._handle_chunk(amt)
1414+
# First, check if any data is left in the decoder's buffer.
1415+
if self._decoder and self._decoder.has_unconsumed_tail:
1416+
chunk = b""
1417+
else:
1418+
self._update_chunk_length()
1419+
if self.chunk_left == 0:
1420+
break
1421+
chunk = self._handle_chunk(amt)
14141422
decoded = self._decode(
14151423
chunk,
14161424
decode_content=decode_content,

lib/urllib3/util/retry.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ class Retry:
178178
Sequence of headers to remove from the request when a response
179179
indicating a redirect is returned before firing off the redirected
180180
request.
181+
182+
:param int retry_after_max: Number of seconds to allow as the maximum for
183+
Retry-After headers. Defaults to :attr:`Retry.DEFAULT_RETRY_AFTER_MAX`.
184+
Any Retry-After headers larger than this value will be limited to this
185+
value.
181186
"""
182187

183188
#: Default methods to be used for ``allowed_methods``
@@ -196,6 +201,10 @@ class Retry:
196201
#: Default maximum backoff time.
197202
DEFAULT_BACKOFF_MAX = 120
198203

204+
# This is undocumented in the RFC. Setting to 6 hours matches other popular libraries.
205+
#: Default maximum allowed value for Retry-After headers in seconds
206+
DEFAULT_RETRY_AFTER_MAX: typing.Final[int] = 21600
207+
199208
# Backward compatibility; assigned outside of the class.
200209
DEFAULT: typing.ClassVar[Retry]
201210

@@ -219,6 +228,7 @@ def __init__(
219228
str
220229
] = DEFAULT_REMOVE_HEADERS_ON_REDIRECT,
221230
backoff_jitter: float = 0.0,
231+
retry_after_max: int = DEFAULT_RETRY_AFTER_MAX,
222232
) -> None:
223233
self.total = total
224234
self.connect = connect
@@ -235,6 +245,7 @@ def __init__(
235245
self.allowed_methods = allowed_methods
236246
self.backoff_factor = backoff_factor
237247
self.backoff_max = backoff_max
248+
self.retry_after_max = retry_after_max
238249
self.raise_on_redirect = raise_on_redirect
239250
self.raise_on_status = raise_on_status
240251
self.history = history or ()
@@ -256,6 +267,7 @@ def new(self, **kw: typing.Any) -> Self:
256267
status_forcelist=self.status_forcelist,
257268
backoff_factor=self.backoff_factor,
258269
backoff_max=self.backoff_max,
270+
retry_after_max=self.retry_after_max,
259271
raise_on_redirect=self.raise_on_redirect,
260272
raise_on_status=self.raise_on_status,
261273
history=self.history,
@@ -320,6 +332,10 @@ def parse_retry_after(self, retry_after: str) -> float:
320332

321333
seconds = max(seconds, 0)
322334

335+
# Check the seconds do not exceed the specified maximum
336+
if seconds > self.retry_after_max:
337+
seconds = self.retry_after_max
338+
323339
return seconds
324340

325341
def get_retry_after(self, response: BaseHTTPResponse) -> float | None:

0 commit comments

Comments
 (0)