swift-server / swift-server/async-http-client

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

Open
#866 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
1.1k
Forks
156
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading HTTPClient.Configuration.dnsOverride and the existing execute APIs mentioned in the issue. Determine how a per-request mapping or resolver would reach connection establishment while preserving the original host for SNI, certificate validation, and logging. Done means one client can issue requests with changing overrides without recreating its connection pool.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.