Skip to content

Instantly share code, notes, and snippets.

Last active January 13, 2023 23:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
How to select HTTP/3 when the support goes "release" for real

HTTP/3 options

  • "HTTP/3 please". Attempt to use HTTP/3 but fallback to h1/h2 if h3 does not work. This option makes curl try h3 first and if that has not succeeded after N milliseconds, a second attempt using TLS+TCP is initiated and then the first to connect wins and is used. This might then also make h3 not get used if it is too slow. In a future, if a significant portion of servers run HTTP/3, we could consider enabling this option by default.

  • "HTTP/3 only". Only try HTTP/3 against the given server and fail if h3 was not availble or otherwise possible.

  • alt-svc. The alt-svc options are already there, supported and work for HTTP/3 as well. However, the alt-svc logic in curl still lacks proper fallback on failures.

This means there is no way to ask for HTTP/3 but if it fails, insist on HTTP/1.1 (avoid HTTP/2) but I cannot see any good reason to insist on having that.

Step one

We provide --http3 and --http3-only (via PR10264) for the tool. One option with fallback and another without.

Those two option have their exact counterparts in libcurl's CURLOPT_HTTP_VERSION option:

  • CURL_HTTP_VERSION_3 with fallback
  • CURL_HTTP_VERSION_3ONLY without fallback

Step two

Rework the HTTP version selection for the command line tool:

  • drop the two separate HTTP/3 options
  • introduce --http-version [spec] where [spec] part can be a range, or a single version with some minor restrictions

With a litle luck, this option replaces all the other HTTP selection options.

  • [max version]-[lowest version] - For example 3-2 allows version 3 or 2.
  • [max version]- - For example 3-, use version three and allow curl to select any lower version
  • [version] - For example 3, use version three do not accept any other version

Step three

Mark HTTP/3 support non-eperimental

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment