Skip to main content

Module http

Module http 

Source
Expand description

The HTTP seam: one request/response shape, two backends.

§Why a trait rather than reqwest directly

Everything worth testing about this client sits above HTTP — whether both proxy headers went out, whether a mint happened inside the retry path, whether a reconnect resumed at the right byte. reqwest opens real sockets, so none of those are reachable from a test that does not stand up a server, and the two that matter most are only reachable by inspecting a request that was already sent.

So HttpBackend is the seam. Production is ReqwestBackend; a test supplies a recorder that keeps every request head, or a backend that writes bytes at a simulated network. The daemon made the mirror-image choice with axum::serve::Listener, and for the same reason: the simulator stays out of the shipping artifact.

§Streaming is a separate method

HttpBackend::send collects the whole body, which for an SSE attach means it returns once the command is over — and every property worth checking about a stream is only observable partway through. HttpBackend::open_stream hands back a chunk source instead.

Structs§

HttpRequest
One request, already fully addressed: absolute URL, every header, whole body.
HttpResponse
One response, body already collected.
ReqwestBackend
The production backend: one pooled reqwest client.

Traits§

ChunkSource
A body arriving in pieces.
HttpBackend
The seam. Production and simulated transports implement this.

Type Aliases§

OpenStream
A streaming response: the head, and the body still to arrive.
SharedBackend
A backend behind an Arc, which is what a crate::session::Session holds.