Skip to main content

Module http3

Module http3 

Source
Expand description

HTTP/3 over QUIC (feature http3). HTTP/3 over QUIC (feature http3).

HTTP/3 is a different transport, not a different framing of the same one: it runs over QUIC on UDP, so it needs its own socket and its own listener rather than an extra branch inside the TCP engine. That is why this is started separately from App::start, and why an application that wants both runs both.

use churust_core::{Call, Churust};

let app = Churust::server()
    // Tell HTTP/1.1 and HTTP/2 clients that h3 is available on the same
    // port, so they can upgrade themselves on the next request.
    .advertise_http3(8443)
    .routing(|r| {
        r.get("/", |_c: Call| async { "served over h3" });
    })
    .build();

churust_core::http3::serve(
    app,
    "0.0.0.0:8443".parse().unwrap(),
    "cert.pem",
    "key.pem",
)
.await

§How clients find it

They do not, on their own. A browser reaches a new origin over TCP, and only moves to h3 if the response says h3 exists. That is the Alt-Svc header, and AppBuilder::advertise_http3 is what sets it. Serving h3 without advertising it means almost nothing will ever use it.

§What is supported

Request routing, headers, request bodies and response bodies, including streamed ones, through the same pipeline every other transport uses: a handler cannot tell which transport it is answering.

WebSockets are not carried over h3. The upgrade mechanism there is Extended CONNECT from RFC 9220, which is a different handshake from the HTTP/1.1 one the ws feature implements, and pretending otherwise would produce a connection that fails at the first frame.

Structs§

Http3Server
A bound QUIC listener, not yet serving.

Functions§

serve
Serve app over HTTP/3 on addr until the process ends.
serve_with_config
Serve app over HTTP/3 with an already-built QUIC configuration.
server_config_from_pem
Build a QUIC server configuration from a PEM certificate chain and key.