Skip to content

Support dns_options for per-request proxies in .get() and .post() #591

@KiraOsago

Description

@KiraOsago

Problem Description

Currently, dns_options (like add_resolve or IPV4_ONLY) configured on a Client are only applied to proxies defined at the Client level during initialization.

If a proxy is passed dynamically per-request (e.g., client.get(url, proxy=...)), the Client ignores its globally configured dns_options for that specific connection. This leads to unexpected DNS resolution failures (for instance, hickory-dns hanging on IPv6 routes), even though add_resolve was explicitly configured on the Client to bypass the resolver for the proxy host.

Proposed Solution

Please consider adding support for dns_options on dynamically passed proxies. This could be done in two ways:

  1. Allow dns_options in the Request API: Add dns_options as a valid parameter in .get(), .post(), and the Request TypedDict so it can be passed alongside the per-request proxy.
  2. Inherit Client options: Automatically apply the Client's global dns_options to the temporary connection pool created for the per-request proxy.

Use Case

When rotating proxies dynamically on a single long-lived Client (to reuse connection pools and cookie jars), rebuilding the entire Client just to apply add_resolve to the new proxy host is inefficient. Allowing dns_options at the request level would gracefully solve this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-upstreamBlocked: upstream. Depends on a dependency to make a change first.bugSomething isn't workingdependenciesPull requests that update a dependency file

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions