Skip to content

feat: add WithHTTPClient option#35

Open
lidel wants to merge 1 commit into
masterfrom
feat/with-http-client
Open

feat: add WithHTTPClient option#35
lidel wants to merge 1 commit into
masterfrom
feat/with-http-client

Conversation

@lidel
Copy link
Copy Markdown
Member

@lidel lidel commented Jun 4, 2026

Problem

DoH requests always went through http.DefaultClient, with no way for callers to supply their own other than overriding the global client. That blocks setting a request timeout, routing through a proxy, customizing TLS, or putting a caching transport (or CDN-fronted client) in front of the resolver.

Fix

  • Add a WithHTTPClient(*http.Client) option that threads a caller-supplied client through every DoH request.
  • Default to http.DefaultClient, so behavior is unchanged when the option is unused.
  • Reject a nil client at construction.

This makes the HTTP transport pluggable, which is the prerequisite for any of the above (timeouts, proxy, TLS, shared HTTP caching).

Requests always went through http.DefaultClient, so callers could not
set timeouts, a proxy, custom TLS, or a caching transport. Add a
WithHTTPClient option that threads a caller-supplied *http.Client
through every DoH request; the default stays http.DefaultClient.
@lidel lidel requested review from MarcoPolo and sukunrt June 4, 2026 11:46
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.

1 participant