h11
A pure-Python, bring-your-own-I/O implementation of the HTTP/1.1 protocol.
Repository Health
Technical Analysis
h11 implements the HTTP/1.1 protocol as a pure state machine with no I/O of its own: callers feed it bytes read from a socket and feed it events to send, and h11 tells them what bytes to write and what HTTP events (request lines, headers, body chunks) occurred. This “sans-I/O” design means h11 works identically whether it’s driven by blocking sockets, asyncio, Trio, or any other concurrency model.
Because it owns only protocol parsing and serialization — not networking, TLS, or connection pooling — h11 has become the HTTP/1.1 engine underneath several popular Python HTTP libraries and servers, including httpx, urllib3 (optionally), and the uvicorn/hypercorn ASGI server ecosystem, letting each of them bring their own I/O and concurrency strategy on top of the same well-tested protocol implementation.
What You Get
- A
Connectionobject that tracks HTTP/1.1 connection state and exposesnext_event()/send()for parsing and generating protocol traffic - Explicit event types (
Request,Response,Data,EndOfMessage,ConnectionClosed) representing every stage of an HTTP/1.1 exchange - Correct handling of protocol edge cases: chunked transfer encoding,
Connection: close, keep-alive, and pipelining - Full decoupling from any specific I/O model, so it can be driven by blocking sockets, asyncio, Trio, or Curio identically
- A fuzz-tested, specification-focused implementation validated against a corpus of malformed/adversarial HTTP input
Common Use Cases
- Implementing an HTTP client or server library that wants to bring its own I/O/concurrency model instead of inheriting one
- Powering the HTTP/1.1 layer of an ASGI server (e.g. Uvicorn, Hypercorn) or async HTTP client (e.g. httpx)
- Building protocol-level tooling (proxies, testing harnesses, protocol analyzers) that needs precise control over HTTP/1.1 parsing without a full networking stack
- Writing tests that exercise HTTP/1.1 edge cases (chunked encoding, malformed headers) without needing a live socket
Under The Hood
Architecture h11’s core is _connection.py, which implements a Connection class as an explicit state machine (_state.py defines the state transitions) tracking whether the connection is a client or server, and its current phase (idle, sending headers, sending body, done, etc). _events.py defines the public event types that next_event() returns and that callers pass to send(); _readers.py/_writers.py implement the actual byte-level parsing and serialization for each state, and _receivebuffer.py manages incrementally buffering partial reads. _abnf.py encodes the HTTP grammar rules from RFC 9110/9112 used to validate headers and request/status lines.
Tech Stack Pure Python with zero runtime dependencies, distributed as a standard setup.py-based sdist/wheel, fully typed (ships py.typed), and continuously fuzz-tested via a dedicated fuzz/ harness against malformed HTTP input.
Code Quality The h11/tests directory (12 files) provides dense coverage of protocol edge cases — chunked encoding, header parsing, connection state transitions, and error handling — reflecting the project’s explicit design goal of being a rigorously correct, specification-driven implementation rather than a convenience wrapper. The sans-I/O architecture itself is a code-quality choice: by refusing to touch sockets, the state machine is fully deterministic and unit-testable without mocking network calls.
API Design The public surface is deliberately small: construct a Connection, call .send(event) to generate bytes for the wire, feed received bytes to .receive_data(), and call .next_event() in a loop to get back parsed events. This event-loop-agnostic API requires callers to write their own I/O glue code, which is more upfront work than a batteries-included HTTP client, but gives library authors full control over concurrency and networking behavior.
Used by 15 apps in this directory
Promptfoo
AI Development
An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.
rowboat
AI Assistants · AI Development
Build, test, and deploy multi-agent AI workflows with a visual editor, RAG data sources, MCP tool integration, and a production-ready REST API.
Scalar
Developer Tools
Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.
SWIRL
Data Engineering · Databases · Search
Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.
timesfm
AI Development · Analytics
A pretrained decoder-only foundation model by Google Research that delivers zero-shot time series forecasting with calibrated quantile prediction intervals — no training required.
Windmill
Automation · Developer Tools
Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.