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
Agno
Devops · AI Development · Automation
Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.
argilla
AI Development · Data Engineering
Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.
ClickHouse
Databases · Analytics · Data Engineering
Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.
CubeSandbox
Developer Tools · Security · AI Agents
Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.
GPT Researcher
Productivity · AI Assistants
The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.
Helicone
Monitoring · AI Development · Analytics
An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.
knowhere
AI Development · Developer Tools
Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.
marimo
Developer Tools · Data Engineering
A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.
OSV.dev
Security
Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.