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§
- Http3
Server - A bound QUIC listener, not yet serving.
Functions§
- serve
- Serve
appover HTTP/3 onaddruntil the process ends. - serve_
with_ config - Serve
appover HTTP/3 with an already-built QUIC configuration. - server_
config_ from_ pem - Build a QUIC server configuration from a PEM certificate chain and key.