Expand description
Unified outbound HTTP client.
Every provider/API call in the workspace should eventually go through
HttpClient so that timeout, retry, body-size and cancellation policies
are defined in one place instead of drifting across 20 crates.
§Policies
- Two profiles:
Profile::Api(connect 10s, total 60s, body capped at 10 MiB) andProfile::Sse(connect 10s, total 300s, response body is streamed, not buffered). - Retries are attempted only for statuses
408/429/500/502/503/504and for connection/timeout transport errors.501and505are returned immediately — retrying a “not implemented”/“version unsupported” response just hammers a server that can never succeed. Retry-Afteris honored in both its forms (delta-seconds and IMF-fixdate, per RFC 9110) and is never truncated by the backoff cap.- Backoff uses full jitter; retry sleeps are cancellation-aware.
- For SSE, retries happen only while establishing the stream (before the first successful response). A stream that breaks mid-flight is not reconnected, because that would silently replay already-delivered events.
§SSRF
This client is for public provider endpoints and does not perform
private-address pinning. Callers that fetch user-supplied URLs (tools, web
loaders) must keep using crate::ssrf::guarded_get and friends.
Structs§
- Bounded
Response - A fully buffered response with status and headers.
- Http
Client - A configured outbound HTTP client. Cheap to clone (wraps an Arc’d pool).
- Http
Client Builder - Builder for
HttpClient. Construct viaHttpClient::api/HttpClient::sseorHttpClient::builder. - Request
Options - Per-request overrides applied on top of the client defaults.
- Retry
Policy - Retry policy: attempt count, backoff bounds and transport classification.
Enums§
- Http
Error - Errors produced by the unified HTTP layer.
- Profile
- Selects the built-in timeout/body profile.
- Transport
Retry Mode - Which transport errors are eligible for retry.
Constants§
- DEFAULT_
API_ MAX_ BYTES - Default response body cap for API calls: 10 MiB.
- DEFAULT_
API_ TOTAL_ TIMEOUT - Default total (connect + send + response headers) budget for API calls.
- DEFAULT_
CONNECT_ TIMEOUT - Default TCP connect timeout for both profiles.
- DEFAULT_
SSE_ TOTAL_ TIMEOUT - Default total budget for establishing an SSE stream.
- ERROR_
BODY_ BYTES - Upper bound read from an error response body so messages stay bounded.
Functions§
- compute_
backoff - Full-jitter backoff: uniform in
[0, min(base * 2^attempt, max_delay)]. - is_
retryable_ status - Returns true for the closed set of retriable statuses: 408, 429, 500, 502, 503, 504. Notably 501/505 are NOT retriable.
- normalize_
base_ url - Canonical base-URL normalization used by every provider config.
- parse_
retry_ after - Parses a
Retry-Afterheader, accepting both delta-seconds and an IMF-fixdate. A date in the past resolves toDuration::ZERO.
Type Aliases§
- SseStream
- Boxed SSE byte stream.