Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy configuration to ConnectionPool. #974

Merged
merged 5 commits into from
Nov 15, 2024

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Oct 29, 2024

Closes #973

  • Documentation.
  • Implementation.
  • Tests.
  • Changelog.
  • Deprecate HTTPProxy/AsyncHTTPProxy/SOCKSProxy/AsyncSOCKSProxy classes.

This would allow for some refactoring cleanup, eg the following...

https://github.com/encode/httpx/blob/eeb5e3c2a3ff2403ec47b5926715ecd61143d92d/httpx/_transports/default.py#L148-L208

Could become...

proxy_config = httpcore.Proxy(
    url=proxy.url,
    auth=proxy.auth,
    headers=proxy.headers,
    ssl_context=proxy.ssl_context,
) if proxy else None

self._pool = httpcore.ConnectionPool(
    ssl_context=ssl_context,
    proxy=proxy_config,
    max_connections=limits.max_connections,
    max_keepalive_connections=limits.max_keepalive_connections,
    keepalive_expiry=limits.keepalive_expiry,
    http1=http1,
    http2=http2,
    uds=uds,
    local_address=local_address,
    retries=retries,
    socket_options=socket_options,
)

It also paves the way for us pushing a use_system_proxies config into httpcore.ConnectionPool.

This would be beneficial as we can then drop the gnarly approach of "system proxies are handled through mounting different connection pool instances" in httpx.

https://github.com/encode/httpx/blob/eeb5e3c2a3ff2403ec47b5926715ecd61143d92d/httpx/_client.py#L658-L692

@tomchristie tomchristie merged commit 13e281d into master Nov 15, 2024
5 checks passed
@tomchristie tomchristie deleted the proxy-config-on-connection-pool branch November 15, 2024 10:57
@tomchristie tomchristie mentioned this pull request Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add proxy configuration to httpcore.ConnectionPool
1 participant