Skip to main content

io_http/
lib.rs

1#![no_std]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4//! # io-http
5//!
6//! I/O-free HTTP client coroutines. Every network exchange is a
7//! resumable state machine that emits read and write requests instead
8//! of performing I/O itself: the caller owns the socket and pumps the
9//! coroutine with the bytes it read, whatever the runtime (blocking,
10//! async, in-memory tests). The `client` feature ships a ready-made
11//! std-blocking pump for callers who just want a working client.
12//!
13//! ## Layout: one folder per RFC
14//!
15//! io-http covers HTTP in general; today HTTP/1.0 and HTTP/1.1 are
16//! implemented. The source tree mirrors how the HTTP specification
17//! itself is split, one module per RFC, so the RFC number is the
18//! version discriminator: a future version (HTTP/2, HTTP/3) would slot
19//! in as its own RFC modules alongside the existing ones.
20//! [`rfc9110`] holds the version-agnostic semantics shared by every
21//! wire format: the request and response types, status codes, header
22//! name constants, authentication challenge parsing, and the output
23//! and yield types common to both send coroutines. [`rfc1945`]
24//! implements the HTTP/1.0 wire protocol and [`rfc9112`] the HTTP/1.1
25//! one: each ships its request serialiser and send coroutine, and
26//! HTTP/1.1 adds the response-head parser plus two chunked
27//! transfer-coding decoders (whole-body and streaming).
28//!
29//! Around the wire protocols, [`rfc6750`] and [`rfc7617`] provide the
30//! bearer and basic authorization header helpers, with secrets
31//! redacted from debug output; [`rfc8615`] wraps the HTTP/1.1 send
32//! coroutine into a well-known URI discovery coroutine surfacing the
33//! redirect target.
34//!
35//! Two modules span the RFC modules and therefore live at the crate
36//! root: [`coroutine`] defines the coroutine contract every state
37//! machine implements, and [`sse`] parses W3C Server-Sent Events
38//! frames (a WHATWG HTML Living Standard, not an RFC, hence its own
39//! name). The optional [`client`] module (`client` feature) is the
40//! std-blocking pump: a light client wrapping any stream you opened
41//! yourself, or a full client opening the TCP/TLS connection itself
42//! when one of the TLS features is enabled.
43//!
44//! ## The coroutine contract
45//!
46//! Every coroutine implements [`coroutine::HttpCoroutine`]: a resume
47//! method taking the bytes read since the last step and returning
48//! either an intermediate yield or a terminal completion. Standard
49//! coroutines yield the shared read/write requests of
50//! [`coroutine::HttpYield`]; richer coroutines declare their own yield
51//! type, like the send coroutines surfacing 3xx redirects to the
52//! caller instead of following them, or the streaming decoders
53//! yielding one frame at a time. Completion carries a per-coroutine
54//! output or error; the [`http_try`] macro chains an inner coroutine
55//! step inside an outer resume, re-yielding and short-circuiting like
56//! the question mark operator.
57//!
58//! ## Conventions
59//!
60//! The crate is no_std with alloc; std only enters behind the `client`
61//! feature. Public items carry the version-agnostic `Http` prefix when
62//! they belong to the shared semantics, and the version-scoped
63//! `Http10` / `Http11` prefix when they are tied to a wire format; the
64//! `Sse` family keeps its own deliberate namespace. Logging follows
65//! the library rules: state changes at debug level, in-process steps
66//! and data dumps at trace level.
67
68extern crate alloc;
69#[cfg(feature = "client")]
70extern crate std;
71
72#[cfg(feature = "client")]
73pub mod client;
74pub mod coroutine;
75pub mod rfc1945;
76pub mod rfc6750;
77pub mod rfc7617;
78pub mod rfc8615;
79pub mod rfc9110;
80pub mod rfc9112;
81pub mod sse;