# HTTP/2 URL: /docs/protocols/http2/ Section: protocols Tags: http2, h2, protocol, multiplexing -------------------------------------------------------------------------------- Overview HTTP/2 support is provided via the h2 library. 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 h2 via 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. flowchart LR Conn["Connection\n(1 TCP socket)"] Conn --> S1["Stream 1\nGET /index.html"] Conn --> S3["Stream 3\nGET /style.css"] Conn --> S5["Stream 5\nGET /script.js"] Conn --> S7["Stream 7\nGET /data.json"] 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. The http_version field is "2": { "type": "http", "asgi": {"version": "3.0"}, "http_version": "2", "method": "GET", "path": "/", "headers": [...], ... } See Also HTTP/1.1 — Default protocol WebSocket — Including WebSocket over HTTP/2 TLS — Setting up TLS for HTTP/2 -------------------------------------------------------------------------------- Metadata: - Word Count: 245 - Reading Time: 1 minutes