Skip to main content

Crate micro_h2

Crate micro_h2 

Source
Expand description

A minimal HTTP/2 client: no_std, allocation-free, sans-io.

§Scope

Enough HTTP/2 to be a client and no more. No server, no push, no priority, no trailers, and a small fixed number of concurrent streams. That is not laziness — HTTP/2’s full surface is large, and every feature carried is another piece of state that has to be right. What this omits, it omits explicitly, and refuses rather than half-implements.

§What is genuinely hard here

Two things, and both fail silently rather than loudly:

HPACK’s dynamic table is connection state built from the peer’s stream. Skipping an insertion does not lose a header; it shifts every subsequent index, so later headers decode as different headers. See hpack::dynamic.

Flow control is not optional. A receiver starts with a 65535-byte window per stream and per connection, and a sender that has exhausted it simply stops. A long-poll streaming a netmap will deliver exactly 65535 bytes and then hang, which looks like a server fault and is not. See conn.

§Sans-io

conn::Connection never touches a socket. It is fed the bytes that arrived and writes the bytes to send, so the same code runs over TCP, over a ts2021 Noise channel, and over a captured session in a test.

let mut connection = micro_h2::Connection::new();
let mut out = [0u8; 256];
let written = connection.start(&mut out).unwrap();
assert!(written > 24); // client preface plus SETTINGS and WINDOW_UPDATE

Re-exports§

pub use conn::Connection;
pub use conn::Event;
pub use frame::FrameHeader;
pub use frame::FrameType;

Modules§

conn
A client connection: one HPACK context, a few streams, and flow control.
frame
HTTP/2 framing (RFC 7540 section 4).
hpack
HPACK (RFC 7541): header compression for HTTP/2.

Enums§

Error