'How does a browser know if a site supports HTTP/3?

I have a kind of the same question as How does a browser know if a site supports HTTP/2?. I am wondering how the browser knows website support http3.

I am using safari and turned on the http3 support. Then I go to https://cloudflare-quic.com and the protocol is h3-29. I think my safari explores this website using h3 protocol. How does it know it?



Solution 1:[1]

The spec defines 'Discovering an HTTP/3 Endpoint':

An HTTP origin can advertise the availability of an equivalent HTTP/3 endpoint via the Alt-Svc HTTP response header field or the HTTP/2 ALTSVC frame (ALTSVC), using the "h3" ALPN token.

In this case, Alt-svc is present:

$ curl -i https://cloudflare-quic.com
HTTP/2 200 
...
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400

So a browser receiving this response can attempt its next connection using those three draft versions on the same server, on UDP port 443.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1