Documentation
¶
Overview ¶
Package httpclient is the shared construction point for outbound HTTP transports and clients outside the platform site-proxy regime.
Two regimes coexist by design:
- Platform adapter traffic (login/checkin/balance/model calls through platform.DoWithProxy) uses the pooled transport cache in platform/site_proxy.go, whose timeouts are operator-tunable via the PROXY_*_TIMEOUT_SEC env vars.
- Every other outbound path (proxy executor, channel health probes, admin channel test harness, monitor LDOH proxy, notifications, pricing catalog fetch, OAuth token/session exchange, Codex websocket dial, server healthcheck) builds its transport here so each client carries explicit dial / TLS-handshake / idle bounds and a sized connection pool instead of riding http.DefaultTransport.
Baseline values mirror the axonhub HTTP client baseline (docs/internal/analysis/competitor-study-2026-08.md): dial 30s, TLS handshake 10s, MaxIdleConns 100, IdleConnTimeout 90s.
Index ¶
Constants ¶
const ( DefaultDialTimeout = 30 * time.Second DefaultKeepAlive = 30 * time.Second DefaultTLSHandshakeTimeout = 10 * time.Second DefaultIdleConnTimeout = 90 * time.Second DefaultMaxIdleConns = 100 DefaultMaxIdleConnsPerHost = 20 DefaultExpectContinueTimeout = 1 * time.Second )
Baseline defaults shared by every outbound transport built in this package.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(transport http.RoundTripper, timeout time.Duration, checkRedirect func(*http.Request, []*http.Request) error) *http.Client
NewClient wraps transport with a whole-request timeout and a redirect policy. A zero timeout leaves the total request unbounded (streaming callers); the transport's phase timeouts still apply.
func NewTransport ¶
NewTransport builds an *http.Transport with explicit phase timeouts and a sized idle pool. Proxy resolution keeps http.ProxyFromEnvironment, the behavior these paths historically inherited from http.DefaultTransport.
func NoProxy ¶ added in v0.16.20
NoProxy is an Options.Proxy value that disables proxy resolution entirely: HTTP_PROXY/HTTPS_PROXY/NO_PROXY environment variables are ignored and every request dials its target directly. It is equivalent to a nil Transport.Proxy but can be passed explicitly through Options.
func SharedTransport ¶
SharedTransport returns the process-wide baseline transport for outbound clients whose whole-request timeout is at most sharedResponseHeaderTimeout (telegram notifications, pricing catalog fetch, Codex websocket upgrade, server healthcheck). Callers needing a different header-phase cap must build their own transport via NewTransport instead of mutating this one.
Types ¶
type Options ¶
type Options struct {
DialTimeout time.Duration
TLSHandshakeTimeout time.Duration
ResponseHeaderTimeout time.Duration
IdleConnTimeout time.Duration
MaxIdleConns int
MaxIdleConnsPerHost int
// Proxy overrides the transport's proxy resolution. Nil keeps
// http.ProxyFromEnvironment, the behavior these paths historically
// inherited from http.DefaultTransport. Set NoProxy on paths that must
// never ride an operator-configured HTTP_PROXY (e.g. OAuth token
// exchange).
Proxy func(*http.Request) (*url.URL, error)
}
Options configures NewTransport. Zero values select the baseline defaults. ResponseHeaderTimeout 0 leaves the header phase unbounded: use that only where a caller context or the client Timeout already owns the deadline (SSE stream relays, context-driven probes).