Watchfire
HTTP and rate limits
HTTP. ctx.http() sends requests with a timeout (WATCHFIRE_HTTP_TIMEOUT, 30 s; 10 s to connect), retries
connect errors, timeouts, 429 and 5xx up to 3 times with jittered backoff (honouring Retry-After up to 60 s;
5xx and timeouts are retried for GET, HEAD, PUT, DELETE and OPTIONS only), waits for the host's token
bucket from w.rate_limit(host, rate), and sends User-Agent: <APP_NAME> (smeltery-watchfire). A response body
larger than WATCHFIRE_HTTP_MAX_BODY (10 MiB) fails with HttpError::TooLarge; the body is read in chunks and the
read stops at the limit. The client follows redirects itself (301, 302, 303, 307, 308, at most 5 hops), so
each hop waits for the token bucket of its own host: only to http and https URLs, never from https to http,
and on a hop to another origin only User-Agent, Accept and Accept-Language go along (no Authorization, cookies
or key headers) and no request body (HttpError::Redirect otherwise). .redirects(Redirects::SameOrigin) stays on
one origin, .redirects(Redirects::None) returns the 3xx answer. The default follows a redirect to any http or
https host, addresses on this machine and the private network included (without the headers and body above); an
agent that fetches URLs its users or other sites supply sets .redirects(Redirects::SameOrigin) on those requests
(or HttpOptions::redirects for its client), so a redirect cannot send it to an internal address. Errors and logs
name a URL as
scheme://host:port/path, without its query string or user info. Methods: get(url),
post_json(url, &body), request(method, url) with .header, .bearer, .body, .json, .timeout,
.max_body(bytes), .redirects(policy), .send(); responses have status(), text(), json::<T>(), bytes(),
error_for_status().