h11
A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
This package has a good security score with no known vulnerabilities.
Community Reviews
Powerful HTTP/1.1 state machine, but requires deep protocol understanding
The documentation is thorough but assumes significant HTTP protocol knowledge. You need to understand chunked encoding, connection management, and state transitions. Error messages are generally clear when the state machine catches protocol violations. Type hints are present and helpful for IDE completion, though the event-based API takes time to internalize.
For most developers, higher-level libraries like httpx or aiohttp are better choices. h11 shines when you're building protocol-level tooling, proxies, or need precise control over HTTP wire protocol. It's what powers httpcore (used by httpx), so it's battle-tested in production.
Best for: Building custom HTTP protocol implementations, proxies, or low-level networking tools where you need precise control over the wire protocol.
Avoid if: You need a ready-to-use HTTP client or server - use httpx, aiohttp, or similar high-level libraries instead.
Excellent low-level HTTP/1.1 building block with BYOIO architecture
The API requires understanding HTTP/1.1 state transitions (IDLE → SEND_RESPONSE → DONE, etc.), which has a learning curve but prevents subtle protocol bugs. Connection reuse works well once you understand the state management. No built-in timeout handling means you implement that in your I/O layer. Error messages are informative when you violate protocol rules, though debugging state machine issues initially takes time.
Performance is solid for a pure-Python implementation. The lack of connection pooling or retry logic is intentional—h11 is a building block, not a batteries-included solution. This makes it perfect for frameworks like hypercorn/uvicorn but potentially too low-level for application code.
Best for: Building custom HTTP servers, proxies, or network frameworks where you need precise control over HTTP/1.1 protocol handling and I/O behavior.
Avoid if: You need a batteries-included HTTP client/server with connection pooling and retry logic—use httpx, aiohttp, or requests instead.
Powerful HTTP/1.1 state machine, but requires significant expertise
The API is well-typed with good type hint coverage, making IDE autocomplete helpful. Error messages are clear when protocol violations occur, with specific exception types like ProtocolError that include contextual details. However, the documentation assumes significant HTTP knowledge - there's limited hand-holding for common patterns like chunked encoding or connection reuse.
Day-to-day usage involves managing Connection objects, sending Events through send(), and receiving parsed events via receive_data(). The state machine prevents invalid transitions, which is excellent for correctness but can be confusing when debugging why certain operations fail. You'll spend time reading the source code to understand nuances, especially around connection lifecycle management.
Best for: Building custom HTTP clients/servers or async frameworks where you need precise control over HTTP/1.1 protocol handling and I/O.
Avoid if: You need a batteries-included HTTP library or don't want to implement your own I/O layer - use httpx or aiohttp instead.
Sign in to write a review
Sign In