Skip to main content

nexus_web/http/
mod.rs

1//! Sans-IO HTTP/1.x protocol primitives.
2//!
3//! Built on [`httparse`] for SIMD-accelerated header parsing.
4//! Uses [`ReadBuf`](nexus_net::buf::ReadBuf) for incremental byte buffering.
5//!
6//! - [`ResponseReader`] — parse inbound HTTP responses (used by REST client)
7//! - [`ChunkedDecoder`] — chunked transfer encoding decoder
8//! - [`write_request`] / [`write_response`] — construct outbound HTTP messages
9//!
10//! The HTTP client API is in [`rest`](crate::rest).
11//! `RequestReader` is internal (used for WebSocket upgrade handshake).
12
13mod chunked;
14mod error;
15mod request;
16mod response;
17
18/// Default capacity for HTTP read/decode/scratch buffers.
19///
20/// Sized to comfortably fit a typical HTTP/1.1 head section (request
21/// line + headers up to ~3-4 KiB) in a single allocation, which is the
22/// dominant use site. Also used by `nexus-async-web` as the per-recv
23/// read cap during WebSocket upgrade and REST request/response cycles,
24/// and as the initial capacity of intermediate body / wire / decode
25/// scratch buffers.
26///
27/// Currently a hardcoded internal default. Callers with unusually large
28/// HTTP heads (very long cookies, many or large header values) would
29/// today need to work around by sending fewer headers; a builder knob
30/// is a separate concern.
31pub const HTTP_HANDSHAKE_BUFFER: usize = 4096;
32
33pub use chunked::ChunkedDecoder;
34pub use error::HttpError;
35// RequestReader parses inbound HTTP requests (used for WS upgrade handshake).
36// The public HTTP client API is in `rest::`.
37pub use request::RequestReader;
38pub use response::{
39    Response, ResponseReader, request_size, response_size, write_request, write_response,
40};