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"POST /echo HTTP/1.1\r\n"
    b"Host: example.com\r\n"
    b"Content-Length: 4\r\n"
    b"\r\n"
    b"ping"
)

request = None
body = bytearray()

# Drain every event already available from the received bytes.
while True:
    event = connection.next_event()
    if isinstance(event, h11r.Request):
        request = event
    elif isinstance(event, h11r.Data):
        body.extend(event.data)
    elif isinstance(event, h11r.EndOfMessage):
        if request is None:
            raise RuntimeError("request ended before its Request event")
        break
    elif event is h11r.ReceiveStatus.NEED_DATA:
        raise RuntimeError("the request is incomplete")
    else:
        raise RuntimeError(f"unexpected request event: {event!r}")

# Echo the request body and write every returned byte to the same transport.
response_body = bytes(body)
outbound = connection.send_response(
    200,
    [("Content-Length", str(len(response_body)))],
    reason="OK",
)
outbound += connection.send_data(response_body)
outbound += connection.end_of_message()

See the runnable Python examples for complete round-trip, streaming body, pipelining, zero-copy body, WebSocket Upgrade, and asyncio server lessons.

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.

The Python package supports GIL-enabled CPython 3.10 through 3.14 and free-threaded CPython 3.14t. CI also exercises CPython 3.15 and 3.15t while they are prereleases. Independent Connection instances may run in parallel. Operations on one connection still have protocol order and must be serialized by its caller.

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.1.tar.gz (59.5 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.1-cp314-cp314t-win_arm64.whl (191.5 kB view details)

Uploaded CPython 3.14tWindows ARM64

h11r-0.1.1-cp314-cp314t-win_amd64.whl (198.9 kB view details)

Uploaded CPython 3.14tWindows x86-64

h11r-0.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347.3 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

h11r-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (342.1 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

h11r-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl (310.6 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

h11r-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl (318.3 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

h11r-0.1.1-cp310-abi3-win_arm64.whl (198.9 kB view details)

Uploaded CPython 3.10+Windows ARM64

h11r-0.1.1-cp310-abi3-win_amd64.whl (205.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

h11r-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.5 kB view details)

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

h11r-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (349.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

h11r-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (320.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

h11r-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl (321.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for h11r-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a2345199a199f58bab4e00a590a1c130affc0e98c5c4152e8221f1259f403c6
MD5 2c911a7ed74596fe39336333eb9c778c
BLAKE2b-256 01230f22b12121a92593462893059b1f167e8edb4c8800aa0d355a88b8e8b6ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1.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.1-cp314-cp314t-win_arm64.whl.

File metadata

  • Download URL: h11r-0.1.1-cp314-cp314t-win_arm64.whl
  • Upload date:
  • Size: 191.5 kB
  • Tags: CPython 3.14t, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for h11r-0.1.1-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 1addce7a52d8f88a0e9de94b12cbbfc3d9a867f48a4c9d8c8b44c19ff97da88c
MD5 f9ff4fff43b4b3eeefc02d5d7a859a1c
BLAKE2b-256 44ceb4a56ee0f0ae637c167431bd7987b809f4f3f46e81d0f6e204a6c8134e4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp314-cp314t-win_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.1-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: h11r-0.1.1-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 198.9 kB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for h11r-0.1.1-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 bf51558ef57beb57385dc70da730b3fcc3035f92036e8a19834ee4776126c204
MD5 155237264329f6601df2f8486ded0fec
BLAKE2b-256 d38832625435745f4d494a4976e3b6201458b7c562d1e5734115065ae4bb413a

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp314-cp314t-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.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 126b913ea99facfb792dd02665172fbfa0673728f073b86acd83f0694bf0b22d
MD5 3ef12c8b83c8032dad520ad6b3474dc5
BLAKE2b-256 494706b5a4ba4aab482dff0d918fd6b0872efcac207ffdb94a0ba4ecabaf92db

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp314-cp314t-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.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7d22134c6ad777942273e117bd59425036e5221d9ea3249c82987475830a315c
MD5 7906c6b6094aa17d3dfc58363145006d
BLAKE2b-256 75e79684a4ef91eeaee336aa047ccdf9b4f690a5954a8857d045fdc535eefc20

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp314-cp314t-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.1-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea80b889d6fbc7e7ff05e07ee8e2bc0a48625f99098f2f9d0ce87deaa620a188
MD5 42077c1b394e8cbd25667176db6f5ff1
BLAKE2b-256 f578b84bfa9fb81fe900d34655d070cb6c91f945e6289f831386ad6e76ea2e13

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp314-cp314t-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.1-cp314-cp314t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c2873f5be47bbd9c485cf5dabd089a4f36b95b5c3d1ac0c1e73fde7351fccb98
MD5 a2b9e69c647c80c9a8f3e9955e1f0b12
BLAKE2b-256 c134a1757f1cfe2e3137a6d463d08ac422d7543038cdf19ca9569ce3714b7490

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp314-cp314t-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.

File details

Details for the file h11r-0.1.1-cp310-abi3-win_arm64.whl.

File metadata

  • Download URL: h11r-0.1.1-cp310-abi3-win_arm64.whl
  • Upload date:
  • Size: 198.9 kB
  • Tags: CPython 3.10+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for h11r-0.1.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 acec7454edd686194f4e759dfefd0c424bb54a96b925963a212a4fcc6d35df2c
MD5 944956597780310869f08351eca36f55
BLAKE2b-256 2807a7474645d6f123bf916db993f0f0b734fb1f28ab6d72ae134442ad469d6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-cp310-abi3-win_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.1-cp310-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for h11r-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6c2bb3f4bcef14ee54f28261921bdae823a93db3ad27ec4b6c76775370a36bae
MD5 e41a6173acb6651580dc758bd802a7ed
BLAKE2b-256 fc7d87ef8f5638edde695754792c387608f3a7e9e4d311163eed60b3aa33d661

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-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.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85eaf75ee2c40159c5e6b5ea68685fa220c7ffa1027e40d182aff699ea9a68b2
MD5 5b3ee375f5545ea669889d13df9c769e
BLAKE2b-256 b2c0e6c052293fb4a03d6ac29bbd377ea757b8c942da83433a958ab48caa3829

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-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.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ec96da87ee8d2dd0f9e7bad2d0cf7cc71e5e089a0d6d24ebca635b0430b9afe0
MD5 50c27c4050c1fdb64bc71fe8de313707
BLAKE2b-256 8fb2814fcfc1a84b0461265554db32e9febe6f664db941acab6c4249959ae915

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-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.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

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

File hashes

Hashes for h11r-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6c7b2cfad4747596e43d09a6b650546e73f53a32a9587b5d78c999aa60793eb
MD5 d48e4e90acb3e9b4e538b76599ea5568
BLAKE2b-256 cefc85042e5211c5aa74546027e584533e999033fee4fa12f76b60f81758dcfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-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.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for h11r-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b8f1e5b45c309f225fef3e767356418a3a50dbe3c242e5481cd4c6316f1917d7
MD5 d2aae54417acf15e690e4488ed50e2a0
BLAKE2b-256 cc2085120dafcb48a4b7e87b2295966ba1ba50cc01ecb61d1d75699c4b22283a

See more details on using hashes here.

Provenance

The following attestation bundles were made for h11r-0.1.1-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