Documentation
¶
Overview ¶
Package httpx is the one audited egress client. Every outbound HTTP call goes through New: it has an explicit timeout, caps redirects, refuses an https→http downgrade, strips credential headers once a chain leaves its first host, and refuses to dial a cloud metadata address. ReadBody bounds what a response may put in memory.
Index ¶
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout bounds a whole exchange when New is given no positive timeout.
Variables ¶
var ( // ErrForbiddenAddress reports a dial to a cloud metadata address. ErrForbiddenAddress = errors.New("egress to a cloud metadata address") // ErrTooManyRedirects reports a redirect chain longer than the cap. ErrTooManyRedirects = errors.New("too many redirects") // ErrInsecureRedirect reports an https→http redirect. ErrInsecureRedirect = errors.New("redirect from https to http") // ErrBodyTooLarge reports a response body over the caller's limit. ErrBodyTooLarge = errors.New("response body too large") )
Functions ¶
func New ¶
New returns the egress client. A timeout ≤ 0 means DefaultTimeout. roots, when not nil, replaces the system pool (a private CA such as the broker's).
The guard sits at dial time, not in CheckRedirect, so it covers the first request, every redirect and a DNS name that resolves to a metadata address. No proxy is configured: a proxy would make the dialed address the proxy's.
func NewStreaming ¶
NewStreaming returns New's client without the whole-exchange Timeout, for a WebSocket or SSE exchange, whose length no timeout fits; every other invariant of New holds, the header timeout, the redirect cap and the metadata guard.
Types ¶
This section is empty.