Skip to content

Add per-request DNS override API (curl --resolve / OkHttp Dns-style) #866

@caogaoshuai

Description

@caogaoshuai

Could you please add support for a per-request DNS override that behaves like curl’s --resolve, or similar to OkHttp’s pluggable Dns interface (which lets you override host→IP
resolution on a per-request basis)? At the moment HTTPClient.Configuration.dnsOverride is the only entry-point, so the mapping is effectively static for the lifetime of a client. In
our workloads the host→IP mapping can change every minute, and paying the cost of creating and shutting down separate HTTPClient instances (each with its own connection pool) just to
apply a new override is prohibitively expensive.

The capability we are looking for is:

  • Let a single request supply a temporary host→IP mapping (or a resolver callback).
  • Keep using the original host for SNI/certificate validation and logging.
  • Route the actual TCP/TLS connection to the overridden address.

If the existing execute APIs exposed an optional per-request override, or allowed callers to provide a resolver closure (akin to overriding OkHttp’s Dns.resolve), we could keep the
default behavior while enabling dynamic overrides. We’d greatly appreciate this enhancement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions