Documentation
¶
Overview ¶
Package httpx provides PlugIt's hardened HTTP client (SPEC §5.3: T8, T9, T12). Every outbound request PlugIt makes goes through it.
- SSRF guard: the IP actually being connected is checked at dial time (net.Dialer.Control), so DNS rebinding cannot slip past a hostname check. Private ranges are blocked unless AllowPrivate is set; cloud metadata, unspecified, multicast and reserved addresses are always blocked.
- Redirects are followed only within the same origin, at most MaxRedirects times.
- Response bodies are capped at MaxResponseBytes (after decompression). Reading past the cap returns the capped bytes followed by ErrResponseTruncated instead of io.EOF.
- A total timeout covers dial, headers and body.
- Proxy environment variables are ignored: dialing a proxy would check the proxy's address instead of the target's.
Index ¶
Constants ¶
const ( DefaultTimeout = 30 * time.Second DefaultMaxResponseBytes = 1 << 20 DefaultMaxRedirects = 5 )
Defaults applied when the corresponding Options field is zero.
Variables ¶
var ( ErrBlockedAddress = errors.New("blocked address") ErrRedirectBlocked = errors.New("cross-origin redirect blocked") ErrTooManyRedirects = errors.New("too many redirects") ErrResponseTruncated = errors.New("response truncated at size cap") )
Sentinel errors callers can match with errors.Is.
Functions ¶
func Origin ¶
Origin returns u's origin as scheme://host:port, lowercased, with the scheme's default port filled in. It returns "" when u has no host.
func SameOrigin ¶
SameOrigin reports whether a and b have exactly the same scheme, host and port. Credentials are attached only when this holds against the pinned base_url (SPEC §5.3, T8).