h11

A pure-Python, bring-your-own-I/O implementation of the HTTP/1.1 protocol.

Library
PyPI
v0.16.0
571 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
40 /100 Fair
Development Activity 0
Maintenance 0
Community 80
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 84
Code Quality 85
Innovation 78
Learning Curve 60

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 Connection object that tracks HTTP/1.1 connection state and exposes next_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

TypeScript
98%
MIT

Promptfoo

AI Development

26,358

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.

View details
90
Repo Health
73
Technical
67
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
98%
Apache 2.0

rowboat

AI Assistants · AI Development

18,060

Build, test, and deploy multi-agent AI workflows with a visual editor, RAG data sources, MCP tool integration, and a production-ready REST API.

View details
88
Repo Health
72
Technical
65
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
67%
MIT

Scalar

Developer Tools

16,313

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
65
Dependency
Built with
TypeScript 67%
Vue 29%
Updated 5 days ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,046

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
61
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 1 weeks ago
Python
73%
Apache 2.0

timesfm

AI Development · Analytics

34,750

A pretrained decoder-only foundation model by Google Research that delivers zero-shot time series forecasting with calibrated quantile prediction intervals — no training required.

View details
76
Repo Health
81
Technical
71
Dependency
Built with
Python 73%
HTML 14%
Jupyter Notebook 12%
Updated 1 months ago
Rust
33%
Other

Windmill

Automation · Developer Tools

18,257

Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.

View details
91
Repo Health
82
Technical
64
Dependency
Built with
Rust 33%
TypeScript 24%
Svelte 22%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers