httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Client misses socket_options attribute

Open karpetrosyan opened this issue 5 months ago • 0 comments
trafficstars

Transport classes do support socket_options, though there is no way to tell the client what it needs to pass to the underlying transport constructor when creating it, so there is no way at the client layer to configure socket_options as we do with other transport attributes (http1/2, verify, limits).

The problem can be solved by explicitly passing a transport class to the client, but in that case we are losing the ability to configure proxies through environment variables, so we should handle all the variables ourselves.

The solution that aligns with the current design is to add socket_options so when constructing a transport (proxy or just regular transport), client will know what default socket_options it should pass to that transport

Example:

# Run with HTTPS_PROXY=...
import httpx

httpx.Client(
    socket_options=[...]  # will be passed to the underlying proxy transport that httpx creates for us like other attributes (limits, http1/2)
)

karpetrosyan avatar Jun 10 '25 19:06 karpetrosyan