Is it necessary to fix missed arguments for pools when init transports (Issue originating from httpx) #1160
Replies: 2 comments 1 reply
|
The main thing I'd check here is whether the behavior is coming from httpx2 itself or from the underlying transport layer. A minimal reproduction using the same request with the default transport would help isolate that quickly. If the issue only appears with the affected transport/configuration, that should narrow down where the regression is. |
|
Confirmed on current main, and there's one detail in your write-up worth adjusting because it changes what the fix has to look like. The sync path in if proxy is None:
self._pool = httpcore2.ConnectionPool(
...
uds=uds,
local_address=local_address,
retries=retries,
...
)
elif proxy.url.scheme in ("http", "https"):
self._pool = httpcore2.HTTPProxy(
...
)None of the three make it into either proxy branch, and The adjustment is that retries: int = 0,
local_address: str | None = None,
uds: str | None = None,but Which I'd say makes the SOCKS case the more interesting half of your report rather than a footnote to it. The HTTP side is an uncontroversial oversight with a mechanical fix. On the SOCKS side Either way I'd split those into two changes, since the first needs no discussion and the second needs a call from a maintainer. |
Uh oh!
There was an error while loading. Please reload this page.
I am opening this discussion to address an inconsistency regarding how
HTTPTransportandAsyncHTTPTransporthandle certain parameters when a proxy is configured, and to ask if we can fix this in the next release.The Issue
As mentioned in the
httpxrepository (encode/httpx#2997), when a proxy is activated, several arguments passed tohttpx.HTTPTransportandAsyncHTTPTransportare silently ignored.For example, looking at
httpx2/_transports/default.py(e.g., around L164-183), when aproxyis provided, the underlying connection pools are initialized without forwarding theuds,local_address, andretriesarguments. This means that if a user explicitly setsretries=3while configuring a proxy, the retry mechanism will fail to work as expected without any warning.The Inconsistency
The underlying
httpcore2.HTTPProxyandhttpcore2.SOCKSProxyclasses do actually accept and support these arguments. The limitation is purely withinhttpx2's wrapper layer, which simply fails to pass them down when initializing the proxy connection pool.Documentation Gap
Currently, the official
httpx2documentation does not mention thatuds,local_address, andretriesbecome completely ineffective when a proxy is enabled. This silent failure can be quite confusing for developers who expect consistent transport behavior regardless of whether a proxy is used.All reactions