Skip to main content

A Sans-I/O HTTP/1.1 protocol engine for Python, powered by Rust.

Project description

h11r logo

h11r

A Sans-I/O HTTP/1.1 protocol engine for Python, powered by Rust.

CI codecov PyPI Crates.io docs.rs Python 3.10–3.14 Rust 1.88+ License: MIT

h11r translates between bytes and HTTP events. It handles message framing, connection state, and protocol errors without reading from or writing to the network. Connect it to synchronous sockets, asyncio, Trio, or any other transport that can move bytes.

The protocol core is an independent Rust crate exposed as a typed Python package through PyO3. Its connection model is inspired by h11, while request, response, and trailer head parsing is built on httparse.

h11r is currently alpha software. Its public API may change before the first stable release.

Performance

Python benchmark comparing h11r and h11

The chart compares protocol-layer throughput for h11r and h11 0.16.0 across five equivalent Python HTTP/1.1 workloads that reuse their connections. Each workload uses public APIs and includes protocol state transitions. It does not include socket, TLS, or asynchronous runtime overhead. Higher is faster.

The results were produced by the pyperf benchmark. The raw pyperf result used to render the chart is included for reproduction and inspection. The measurement environment is recorded in the chart. Results will vary with hardware and Python version.

Quick Start

Add h11r to a uv-managed project:

uv add h11r

Or install it with pip:

pip install h11r

This server-side example parses one request and produces a complete response. The caller remains responsible for network I/O.

import h11r

connection = h11r.Connection(h11r.Role.SERVER)

# Bytes received from any synchronous or asynchronous transport.
connection.receive_data(
    b"GET / HTTP/1.1\r\n"
    b"Host: example.com\r\n"
    b"\r\n"
)

request = connection.next_event()
end = connection.next_event()

assert isinstance(request, h11r.Request)
assert request.method == b"GET"
assert isinstance(end, h11r.EndOfMessage)

# Write the returned bytes to the same transport.
outbound = connection.send_response(
    200,
    [("Content-Length", "2")],
    reason="OK",
)
outbound += connection.send_data(b"OK")
outbound += connection.end_of_message()

A Protocol Component, Not an HTTP Client

h11r does not open sockets, choose a concurrency model, or handle TLS, connection pooling, redirects, cookies, or routing. It maintains the protocol state of one HTTP/1.1 connection while higher-level clients, servers, proxies, and test tools decide how to schedule I/O.

It supports client and server roles, HTTP/1.0 peers, Content-Length and chunked framing, keep-alive cycles, informational responses, trailers, and protocol handoff after Upgrade. Input size and header count have independent limits, and local API misuse is reported separately from remote protocol errors.

Acknowledgements

h11r follows the Sans-I/O approach of keeping protocol state separate from network I/O. Its connection lifecycle and event model are inspired by h11. It is not a drop-in replacement for h11; it is a Rust-powered Python implementation built in the same tradition.

Low-level HTTP head parsing is provided by httparse. h11r owns the full message framing, connection state machine, resource boundaries, and Python API.

Contributing

See CONTRIBUTING.md for development and release guidance.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h11r-0.1.0.tar.gz (56.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

h11r-0.1.0-cp310-abi3-win_amd64.whl (205.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

h11r-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

h11r-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (350.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

h11r-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (320.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

h11r-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl (321.1 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file h11r-0.1.0.tar.gz.

File metadata

  • Download URL: h11r-0.1.0.tar.gz
  • Upload date:
  • Size: 56.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for h11r-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4105b60acdf1477b859fc6af304f458fd787b63fba055fa6425ad2b55264d769
MD5 769d4ff10853b692b2bff162d9c6a1ee
BLAKE2b-256 e7063c9a8f848ce5faa4e7d9dfe34d314b3aad97d792f73cfb6b0aed6ae64865

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.0.tar.gz:

Publisher: release.yml on cnzakii/h11r

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file h11r-0.1.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: h11r-0.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 205.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for h11r-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0b780413eb21311eb0912d2ff0170cc5702893c68fe9c923330cd1d87cdb614d
MD5 834ff7e07091ee375641bfa7fcc8a88f
BLAKE2b-256 64c8a31eba5bcfb8e5eb8c5ba60c9a1943662f72698afd5bbd719611c85c2925

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on cnzakii/h11r

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file h11r-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for h11r-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 406f73738154cf362719b593460badc97fb8946f92ffab73881ce36475c0fd0f
MD5 96d5ee989c1dedf340121073ba165286
BLAKE2b-256 d0ffb796b3e79cf2a5ed2268c174785f8b97ffd08a3f565130308f0d4e887f1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on cnzakii/h11r

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file h11r-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for h11r-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b2319eba78b40108d4601877e3df2ec2ae3b3154a347558b32ed0e808744abee
MD5 4790ff01c8950550531184f2f0191b14
BLAKE2b-256 de07fbd4da2ab56d399d2e6e4e4d9aefad29ea7c7b1cb0df7ea7e9115f2cf887

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on cnzakii/h11r

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file h11r-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: h11r-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 320.3 kB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for h11r-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 100908f725679506741d88bf331e87923b35322977f17b384e3fa6968cfe8b67
MD5 dbf2e77e6a595f978253f6b635254a33
BLAKE2b-256 27b3b91f83ea8ec470d9659eccd4616ce5a129f7357fa8c1242595f5326f55c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on cnzakii/h11r

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file h11r-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for h11r-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b75a41bfe599f782fcbaa35c0d5a2cbef8f61f13881f757163a3c4275fb5a8c0
MD5 ab8b683567860706ff6177332bce33d2
BLAKE2b-256 40cb1d46b93bd2b24578dc5d2f3ffc073724c5f304622f3b2d8f3d2214fdbc4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on cnzakii/h11r

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page