Home

h11

h11 is an open-source, pure-Python implementation of the HTTP/1.1 protocol state machine. It provides a lightweight, event-driven interface for encoding and decoding HTTP/1.1 messages in accordance with RFC 7230 through RFC 7235. The library is designed to be a building block rather than a full networking stack, focusing on correctness and robustness.

Design and API

h11 exposes a Connection object that can operate in either client or server mode. The library translates

Usage and role

As a protocol engine, h11 does not perform socket I/O or concurrency control. Applications integrate h11 with

Limitations and scope

h11 implements HTTP/1.1 only and does not provide HTTP/2 support or TLS functionality. It is intended for

between
a
stream
of
bytes
and
a
sequence
of
high-level
events,
such
as
requests,
responses,
data
chunks,
and
message
termination.
Users
feed
incoming
bytes
into
the
connection
and
obtain
bytes
to
send
back
over
a
socket,
while
the
connection
manages
the
HTTP/1.1
state
machine,
including
header
parsing,
body
streaming,
and
message
boundaries.
It
handles
protocol
details
such
as
keep-alive
behavior
and
the
interplay
between
Content-Length
and
chunked
transfer
encoding.
The
API
is
designed
to
be
simple
and
dependency-free
beyond
the
Python
standard
library.
their
I/O
loop
or
framework,
using
the
library
to
interpret
and
construct
HTTP
messages
while
managing
buffering
and
network
transport
themselves.
This
separation
makes
h11
a
common
choice
as
a
low-level
component
in
higher-level
HTTP
clients
and
servers.
use
as
part
of
larger
systems
that
implement
the
networking,
persistence,
and
higher-level
application
logic
around
HTTP
communications.