Building an HTTP/3 server from scratch takes more than sending frames over QUIC. Part 2 of a hands-on series in Go turns the earlier groundwork into a working HTTP/3 server and client that interoperate with curl, the quic-go http3 package and a web browser.
Part 1 covered opening and closing QUIC streams, HTTP/3 variable-length integer framing, and a QPACK encoder and decoder adapted from HTTP/2 HPACK code. That was enough to exchange HEADERS and DATA frames over a single stream. Negotiation, a control stream and a request loop were still missing.
How browsers learn a host speaks HTTP/3
HTTP/2 negotiation is simple because it shares TCP and TLS with HTTP/1.1. The client lists “h2” and “http/1.1” in its TLS ClientHello on TCP port 443, and the server picks one. QUIC runs on UDP, so that route is closed.
Browsers have two alternatives. The first is the Alt-Svc response header. A value such as h3=”:443″; ma=86400 tells the browser that port 443 also speaks h3 for the next 86,400 seconds, or 24 hours, so it can switch to QUIC on its next request. A Go server can listen on TCP and UDP port 8443 in the same binary, since the two port spaces are separate.
The second is a DNS HTTPS record, defined in RFC 9460. With one published, a lookup returns alpn=”h3,h2″, and the browser can open UDP port 443 on its very first request without a TCP round trip. The author prefers this method, but support differs between browsers, so a real deployment may need both.

Testing the HTTP/3 server locally
Local testing has a catch. Chrome’s QUIC client rejects self-signed certificates outright, with no way to click through a warning. Chrome also has no reason to try UDP on localhost:8443 without an Alt-Svc header or DNS record. The fix for the certificate is mkcert, which creates a local certificate and installs it in the system trust store.
curl is simpler. Running curl –http3-only -k still accepts self-signed certificates over QUIC. The built-in curl on macOS lacks HTTP/3 support, so the author used a build from mise. For Chrome, the –origin-to-force-quic-on flag, together with –enable-quic, makes it speak HTTP/3 directly to localhost:8443 without a separate TCP server.
Wrapping quic-go
A small Conn interface in transport.go sits around quic-go. It exposes methods to accept and open bidirectional streams, plus accept and open one-way streams. For now those calls pass straight through to quic-go. In Part 3, the series swaps in its own UDP implementation behind the same interface.
The control stream and server loop
HTTP/2 sent SETTINGS on stream 0. QUIC reserves no stream for that, and stream 0 was already used for the echo request in Part 1. Under RFC 9114 section 6.2.1, each side must open its own one-way control stream. The first byte written is a varint naming the stream type (0x00 for control), followed by a SETTINGS frame (0x04).
That stream has to stay open for the life of the connection. Closing it triggers an H3_CLOSED_CRITICAL_STREAM error, so the helper that writes the settings leaves it open. It sets the QPACK maximum table capacity to 0, because the series’ decoder supports only the static table and string literals, and curl and Chrome must not send dynamic table updates.
For every new QUIC connection, the server opens the control stream, starts a goroutine to drain the client’s one-way streams, and then accepts request streams in a loop, handling each in its own goroutine.
Plugging into http.Handler
Each request handler reads the first HEADERS frame, decodes the QPACK fields into an *http.Request, and passes it to the server’s Handler. A body reader pulls DATA frames off the stream as the handler consumes the body, and a response writer encodes headers and body back onto it. If the handler never sends headers, the server defaults to 200 OK. Because the server speaks the standard interface, ordinary Go handlers work unchanged.
The client and what comes next
The client mirrors the server with the same Do(req) signature built in the HTTP/2 series. It dials QUIC, sends its control stream, opens a request stream, writes HEADERS and DATA, closes its write side so the server sees EOF, then reads the response. The connection stays open until the caller closes the response body.
The demo runs three routes (/, /headers and /echo). Part 3 replaces quic-go underneath the interface with a hand-built UDP layer.
Source: kmcd.dev