Documentation
¶
Overview ¶
Package httpclient owns the process-wide outbound HTTP client so every outbound call shares one timeout and one seam tests can replace. It depends on nothing else in the tree, which is what lets low-level packages (jwtutils) make network calls without importing the utils grab-bag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchBounded ¶
FetchBounded GETs url and reads at most maxBytes of the body, so a hostile or misbehaving peer cannot stream unbounded data into memory. A nil client uses the shared one.
func SetSSRFSafe ¶
func SetSSRFSafe(client Client)
Types ¶
type Client ¶
type Client interface {
Do(req *http.Request) (res *http.Response, err error)
Get(url string) (res *http.Response, err error)
Post(urstring, bodyType string, body io.Reader) (res *http.Response, err error)
PostForm(url string, values url.Values) (res *http.Response, err error)
Head(url string) (res *http.Response, err error)
}
Client is the outbound HTTP surface. An interface so tests substitute a transport-level double.
func Get ¶
func Get() Client
Get returns the shared client, building the default on first use so a caller never gets nil because initialization order put it ahead of the setup path.
func GetSSRFSafe ¶
func GetSSRFSafe() Client
GetSSRFSafe returns a client for fetching URLs an untrusted caller controls. Unlike Get it refuses redirects and refuses to connect to any non-public address, so it must not be used for deliberate link-local calls such as the ECS task-metadata endpoint.