|
| 1 | +From f05b1329126d5be6de501f9d1e3e36738bc08857 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Illia Volochii < [email protected]> |
| 3 | +Date: Wed, 18 Jun 2025 16:25:01 +0300 |
| 4 | +Subject: [PATCH] Merge commit from fork |
| 5 | + |
| 6 | +* Apply Quentin's suggestion |
| 7 | + |
| 8 | +Co-authored-by: Quentin Pradet < [email protected]> |
| 9 | + |
| 10 | +* Add tests for disabled redirects in the pool manager |
| 11 | + |
| 12 | +* Add a possible fix for the issue with not raised `MaxRetryError` |
| 13 | + |
| 14 | +* Make urllib3 handle redirects instead of JS when JSPI is used |
| 15 | + |
| 16 | +* Fix info in the new comment |
| 17 | + |
| 18 | +* State that redirects with XHR are not controlled by urllib3 |
| 19 | + |
| 20 | +* Remove excessive params from new test requests |
| 21 | + |
| 22 | +* Add tests reaching max non-0 redirects |
| 23 | + |
| 24 | +* Test redirects with Emscripten |
| 25 | + |
| 26 | +* Fix `test_merge_pool_kwargs` |
| 27 | + |
| 28 | +* Add a changelog entry |
| 29 | + |
| 30 | +* Parametrize tests |
| 31 | + |
| 32 | +* Drop a fix for Emscripten |
| 33 | + |
| 34 | +* Apply Seth's suggestion to docs |
| 35 | + |
| 36 | +Co-authored-by: Seth Michael Larson < [email protected]> |
| 37 | + |
| 38 | +* Use a minor release instead of the patch one |
| 39 | + |
| 40 | +Upstream Patch Reference: https://github.com/urllib3/urllib3/commit/f05b1329126d5be6de501f9d1e3e36738bc08857.patch |
| 41 | +--- |
| 42 | + src/pip/_vendor/urllib3/poolmanager.py | 30 +++++++++++++++++++++++--- |
| 43 | + 1 file changed, 27 insertions(+), 3 deletions(-) |
| 44 | + |
| 45 | +diff --git a/src/pip/_vendor/urllib3/poolmanager.py b/src/pip/_vendor/urllib3/poolmanager.py |
| 46 | +index fb51bf7..9cbcb6c 100644 |
| 47 | +--- a/src/pip/_vendor/urllib3/poolmanager.py |
| 48 | ++++ b/src/pip/_vendor/urllib3/poolmanager.py |
| 49 | +@@ -3,6 +3,7 @@ from __future__ import absolute_import |
| 50 | + import collections |
| 51 | + import functools |
| 52 | + import logging |
| 53 | ++import typing |
| 54 | + |
| 55 | + from ._collections import HTTPHeaderDict, RecentlyUsedContainer |
| 56 | + from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme |
| 57 | +@@ -168,9 +169,32 @@ class PoolManager(RequestMethods): |
| 58 | + proxy = None |
| 59 | + proxy_config = None |
| 60 | + |
| 61 | +- def __init__(self, num_pools=10, headers=None, **connection_pool_kw): |
| 62 | +- RequestMethods.__init__(self, headers) |
| 63 | ++ def __init__( |
| 64 | ++ self, |
| 65 | ++ num_pools: int = 10, |
| 66 | ++ headers: typing.Mapping[str, str] | None = None, |
| 67 | ++ **connection_pool_kw: typing.Any, |
| 68 | ++ ) -> None: |
| 69 | ++ super().__init__(headers) |
| 70 | ++ if "retries" in connection_pool_kw: |
| 71 | ++ retries = connection_pool_kw["retries"] |
| 72 | ++ if not isinstance(retries, Retry): |
| 73 | ++ # When Retry is initialized, raise_on_redirect is based |
| 74 | ++ # on a redirect boolean value. |
| 75 | ++ # But requests made via a pool manager always set |
| 76 | ++ # redirect to False, and raise_on_redirect always ends |
| 77 | ++ # up being False consequently. |
| 78 | ++ # Here we fix the issue by setting raise_on_redirect to |
| 79 | ++ # a value needed by the pool manager without considering |
| 80 | ++ # the redirect boolean. |
| 81 | ++ raise_on_redirect = retries is not False |
| 82 | ++ retries = Retry.from_int(retries, redirect=False) |
| 83 | ++ retries.raise_on_redirect = raise_on_redirect |
| 84 | ++ connection_pool_kw = connection_pool_kw.copy() |
| 85 | ++ connection_pool_kw["retries"] = retries |
| 86 | + self.connection_pool_kw = connection_pool_kw |
| 87 | ++ |
| 88 | ++ self.pools: RecentlyUsedContainer[PoolKey, HTTPConnectionPool] |
| 89 | + self.pools = RecentlyUsedContainer(num_pools) |
| 90 | + |
| 91 | + # Locally set the pool classes and keys so other PoolManagers can |
| 92 | +@@ -389,7 +413,7 @@ class PoolManager(RequestMethods): |
| 93 | + kw["body"] = None |
| 94 | + kw["headers"] = HTTPHeaderDict(kw["headers"])._prepare_for_method_change() |
| 95 | + |
| 96 | +- retries = kw.get("retries") |
| 97 | ++ retries = kw.get("retries", response.retries) |
| 98 | + if not isinstance(retries, Retry): |
| 99 | + retries = Retry.from_int(retries, redirect=redirect) |
| 100 | + |
| 101 | +-- |
| 102 | +2.45.2 |
| 103 | + |
0 commit comments