Curl: one-liner to test http/2 support

HTTP/2 supported:

$ curl -sI https://curl.se -o/dev/null -w '%{http_version}\n'
2

HTTP/2 not supported (instead serving 1.1 in this case):

$ curl -sI http://curl.se -o/dev/null -w '%{http_version}\n'
1.1

(curl 7.50.0 or later is required for this command line to work)

HTTP/3

Since curl 7.88.1, if you build curl to support HTTP/3, the above one-liner can be extended to also check for HTTP/3 support like this:

$ curl -sI --http3 https://curl.se -o/dev/null -w '%{http_version}\n'
3

Leave a Comment