Overview
HTTP/2 support is provided via theh2library. Install the extra:
uv add "bengal-pounce[h2]"
HTTP/2 provides:
- Stream multiplexing — Multiple requests over a single TCP connection
- HPACK header compression — Reduced overhead for repeated headers
- Priority signals — Clients can indicate request priority
- Server push — Not implemented (deprecated in most browsers)
Requirements
HTTP/2 requires TLS with ALPN negotiation:
pounce myapp:app --ssl-certfile cert.pem --ssl-keyfile key.pem
When a client connects with TLS and advertises h2via ALPN, Pounce selects the HTTP/2 handler automatically. Clients that only support HTTP/1.1 continue to work.
Stream Multiplexing
In HTTP/2, multiple requests share a single TCP connection. Each request is a "stream" with its own ID. Pounce creates a separate ASGI scope for each stream, so your application handles each request independently.
All streams are processed concurrently within the worker's asyncio event loop.
Priority Signals
Pounce supports HTTP Priority Signals (RFC 9218). Clients can indicate request urgency and whether responses can be delivered incrementally. This information is available in the ASGI scope for framework-level prioritization.
ASGI Scope
HTTP/2 requests produce a standard ASGI HTTP scope. Thehttp_version field is "2":
{
"type": "http",
"asgi": {"version": "3.0"},
"http_version": "2",
"method": "GET",
"path": "/",
"headers": [...],
...
}