6

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?

ccQpein
  • 705
  • 7
  • 20

2 Answers2

7

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.

Joe
  • 29,416
  • 12
  • 68
  • 88
0

It either learns about the capability of the site via a HTTPS record in DNS or else it learns about it via a http/1.1 or http/2 connection (on TCP).

I suppose it could also just give it a go and see if it connects.

Browsers also apparently retain some memory of sites they visited previously.

Long term I would hope that http/3 becomes the default and browsers have to treat older versions as the exception to be detected but that situation is probably eons away.