Skip to main content

openframe-protocol-http

HTTP/ASGI server binding. Wires a QueryHandler/CommandHandler/UseCase (openframe.core.inbound) to a FastAPI route through the shared error mapper and RequestContext builder in openframe-protocol-base, instead of each route hand-mapping HTTPExceptions itself.

Install the [server] extra for the FastAPI/ASGI dependencies — openframe-protocol-http[server].

Wiring example

from openframe.protocol.http import bind_query, bind_command, install_error_handlers

router = APIRouter(prefix="/items")

bind_query(
    router, "/{item_id}",
    handler_dep=get_get_item_handler,
    path_param=("item_id", str),
    response_model=Item,
    not_found_when=lambda item: item is None,
)

bind_command(
    router, "", method="POST",
    handler_dep=get_create_item_handler,
    body_model=Item,
    status_code=201,
    response_model=Item,
)

install_error_handlers(app)

Session transports — bind_session (SSE) and bind_websocket (WebSocket)

Long-lived connections don't fit the one-request/one-response shape above — a handler may send zero or many events over a connection's lifetime, and (WebSocket only) receive zero or many inbound events too. Both bind openframe.core.inbound.SessionHandler[TIn, TOut] (ADR-008, openframe-core) instead of a QueryHandler/CommandHandler:

from openframe.protocol.http import bind_session, bind_websocket

bind_session(router, "/artifacts/stream", handler_factory=lambda: ArtifactUpdates())
bind_websocket(router, "/artifacts/ws", handler_factory=lambda: ArtifactUpdates())

Neither needs a dependency beyond [server] — Starlette's own StreamingResponse (SSE) and WebSocket (WebSocket) cover both. on_open runs — and can reject — before the connection commits (before StreamingResponse sends its 200, before websocket.accept()); a failure after that point (SSE's background production, a WebSocket on_event) is sent in-band via session.send() as a plain {"error": {...}} dict (openframe.protocol.base.send_error_event). See the top-level README's "Session transports" section and ADR-008 for the full contract and the real findings (disconnect translation, TestClient task-scheduling limitation, etc.) behind this binding.

Webhooks — bind_webhook

A webhook is a one-shot exchange, the same CommandHandler/UseCase shape bind_command already fits — bind_webhook adds HMAC signature verification against the raw request body before the handler runs:

from openframe.protocol.http import bind_webhook

bind_webhook(
    router, "/webhooks/orders",
    handler_dep=get_order_paid_handler,
    body_model=OrderPaid,
    signature_header="X-Hub-Signature-256",
    secret=settings.webhook_secret,
)

verify_hmac_sha256 (the default verify) covers the common GitHub/Shopify-style scheme; a missing or invalid signature returns 401 before the body is parsed or the handler runs. See the top-level README's "Webhooks" section for the full reasoning.

HTTP/3 over QUIC — create_quic_config

QUIC is a transport-layer change, not an application-layer one — every binder above already runs unmodified over it, confirmed by a real Hypercorn + aioquic spike. There is no bind_quic; QUIC only needs a different ASGI server (Hypercorn, via the [quic] extra) in place of uvicorn:

from openframe.protocol.http.quic import create_quic_config
from hypercorn.asyncio import serve

config = create_quic_config(bind="0.0.0.0:443", certfile="fullchain.pem", keyfile="privkey.pem")
await serve(app, config)

See the top-level README's "HTTP/3 over QUIC" section for the full reasoning.

Status

Experimental, M1-M7 of the project's own build plan. TransportConformanceTests, RemoteClientConformanceTests, and SessionConformanceTests (all openframe-protocol-base) pass against this package for real. HTTP was the first transport to prove the inbound handler contract survives a real transport at all; it's since grown session support (SSE, WebSocket), webhooks, and HTTP/3 over QUIC on top of that same foundation.

Metadata

Release files for openframe-protocol-http 0.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openframe-protocol-http 0.11.1
File Size Uploaded Provenance
openframe_protocol_http-0.11.1.tar.gz 40.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openframe-protocol-http 0.11.1
File Interpreter ABI Platform
openframe_protocol_http-0.11.1-py3-none-any.whl Python 3 none any Details

Total release size: 69.7 kB

Release files / openframe_protocol_http-0.11.1.tar.gz

Download URL openframe_protocol_http-0.11.1.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
89a72e021301b1e25b2678787a25c552eea0a8d7a6a11b37074b573c3de19b5b
BLAKE2b-256 checksum
How to use checksums
a7b8b0a71673e3c4f4f1ecb61514f53290d358967b579edc76a971987b27e7bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / openframe_protocol_http-0.11.1-py3-none-any.whl

Download URL openframe_protocol_http-0.11.1-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
358d3ef13cb1778a6c717bdd61fdbf190f3e9406e6317eb3ca4c4040965637e4
BLAKE2b-256 checksum
How to use checksums
377dfd0e75d3428f6b5e0d48d2ec5e2bfa1e2369ccdec42bf69fc6c17d459bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for openframe-protocol-http 0.11.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page