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:
- 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.
- 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.
Problem Description
Currently,
dns_options(likeadd_resolveorIPV4_ONLY) configured on aClientare only applied to proxies defined at theClientlevel during initialization.If a proxy is passed dynamically per-request (e.g.,
client.get(url, proxy=...)), theClientignores its globally configureddns_optionsfor that specific connection. This leads to unexpected DNS resolution failures (for instance,hickory-dnshanging on IPv6 routes), even thoughadd_resolvewas explicitly configured on the Client to bypass the resolver for the proxy host.Proposed Solution
Please consider adding support for
dns_optionson dynamically passed proxies. This could be done in two ways:dns_optionsin the Request API: Adddns_optionsas a valid parameter in.get(),.post(), and theRequestTypedDict so it can be passed alongside the per-request proxy.Client's globaldns_optionsto 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 entireClientjust to applyadd_resolveto the new proxy host is inefficient. Allowingdns_optionsat the request level would gracefully solve this.