Module http

Module http 

Source
Expand description

2026-09-26: A minimal OpenAI-compatible client over raw HTTP/1.1 on tokio::net::TcpStream, with no TLS: one streaming chat call, measured (chat_stream), plus the blocking, GET, gap and failure helpers in the submodules. Chunked transfer-encoding is decoded by the private reader module before SSE lines are split, so a chunk boundary inside a data: line does not lose a token.

Owner: bench (HTTP client). Invariants:

  • A 200 stream that ends with neither [DONE] nor a finish_reason is an error, never a success.
  • An in-band SSE error frame is an error, never a success.

Re-exports§

pub use gaps::GapSample;
pub use gaps::GapStats;
pub use gaps::itl_ms;
pub use failure::FailureKind;
pub use failure::RequestFailure;
pub use failure::classify;

Modules§

failure
2026-09-26: Why a streamed chat request failed, as data a caller can classify.
gaps
2026-09-26: Arrival-gap accumulator: the within-response jitter instrument.

Structs§

BlockingOutcome
2026-09-26: What a non-streaming chat-completions or Responses request returned.
ChatOutcome
2026-09-26: Everything one request produced, plus its timings.
ToolCall
2026-09-26: A tool call assembled from streamed deltas.

Functions§

chat_blocking
2026-09-26: POST to /v1/chat/completions and read the whole JSON response. Errors on a timeout, a non-200 (with the server’s message when readable) and a body that is not JSON.
chat_stream
2026-09-26: POST body to /v1/chat/completions as an SSE request and measure it. A request that exceeds timeout fails as FailureKind::Timeout.
chat_stream_signalled
2026-10-04: chat_stream, plus a signal: first_token, when given, receives the instant the first token-carrying chunk arrived (the instant ttft_ms is measured to) while the stream is still running. A request that ends before any token drops the sender, so the receiver sees an error instead of waiting.
error_message_from_response
2026-09-26: The message from a complete non-200 HTTP response (status line, headers and body), decoded by the same private reader as streams, chunked bodies included. None unless the response is a non-200 whose body message_from_body can read.
fetch_hardware
2026-09-26: GET /hardware: the serving box’s hardware fingerprint.
get_json
2026-09-26: GET <path> and parse the first JSON value of the reply (a chunked reply carries framing after the document). A status other than 200 is an error that quotes the document.
get_text
2026-10-04: GET <path> and return the body as text, chunked framing decoded, lines joined with \n and each trimmed. A status other than 200 is an error that quotes the body (the streaming client’s Reader does both). A body past TEXT_BODY_LIMIT is an error, so a cut-off page never reads as a page without the series that were cut.
list_models
message_from_body
2026-09-26: The trimmed error.message of an OpenAI-shaped error body. None when the body is not JSON with a non-empty string there, so callers can fall back to the status line.
probe
2026-09-26: Reachability check: GET /v1/models must answer 200 within timeout. Every benchmark driver except vision and video calls it.
responses_blocking
2026-09-26: The same as chat_blocking, against the Responses API (/v1/responses).