client.WithTLSConfig replaces transport, losing proxy support and default timeouts #598

Closed
opened 2026-08-08 05:09:27 +00:00 by the.auditor · 1 comment
Owner

WithTLSConfig in internal/tpagectl/client/client.go sets c.hc.Transport = &http.Transport{TLSClientConfig: tlsConfig}, replacing the default transport entirely. This drops http.DefaultTransport behavior:

  • ProxyFromEnvironment is lost, so HTTP_PROXY/HTTPS_PROXY/NO_PROXY are ignored whenever --insecure or --ca-cert is set — a regression for users behind an HTTP proxy.
  • Default dial/TLS-handshake/idle-connection timeouts are lost.
  • HTTP/2 is not enabled (ForceAttemptHTTP2 unset).

Clone the default transport instead:

tr := http.DefaultTransport.(*http.Transport).Clone()
tr.TLSClientConfig = tlsConfig
c.hc.Transport = tr

See #597

`WithTLSConfig` in `internal/tpagectl/client/client.go` sets `c.hc.Transport = &http.Transport{TLSClientConfig: tlsConfig}`, replacing the default transport entirely. This drops `http.DefaultTransport` behavior: - `ProxyFromEnvironment` is lost, so `HTTP_PROXY`/`HTTPS_PROXY`/`NO_PROXY` are ignored whenever `--insecure` or `--ca-cert` is set — a regression for users behind an HTTP proxy. - Default dial/TLS-handshake/idle-connection timeouts are lost. - HTTP/2 is not enabled (`ForceAttemptHTTP2` unset). Clone the default transport instead: tr := http.DefaultTransport.(*http.Transport).Clone() tr.TLSClientConfig = tlsConfig c.hc.Transport = tr See https://git.lan.thwap.org/thwap/thwap-pagesd/pulls/597
Owner

Fixed in #634: WithTLSConfig clones http.DefaultTransport before setting TLSClientConfig, preserving proxy and timeout behavior (test asserts Proxy is retained).

Fixed in #634: `WithTLSConfig` clones `http.DefaultTransport` before setting `TLSClientConfig`, preserving proxy and timeout behavior (test asserts `Proxy` is retained).
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd#598
No description provided.