I'm currently writing an unit test to check if http/2
is supported.
Is there a curl
one-liner which checks if http/2
is supported and outputs a response that is easy to parse?
Running curl -V will show if your version of curl supports it. If you by some chance already know that your server speaks HTTP/2 (for example, within your own controlled environment where you know exactly what runs in your machines) you can shortcut the HTTP/2 "negotiation" with --http2-prior-knowledge .
Google Chrome offers a quick and easy way to check if HTTP/2 is supported on your SSL-enabled site. First, visit your site in Chrome over HTTPS. There you'll see your site listed with protocol h2, confirming your site works over HTTP/2.
To make a GET request using Curl, run the curl command followed by the target URL. Curl automatically selects the HTTP GET request method unless you use the -X, --request, or -d command-line option.
No. After extensive discussion, the Working Group did not have consensus to require the use of encryption (e.g., TLS) for the new protocol. However, some implementations have stated that they will only support HTTP/2 when it is used over an encrypted connection, and currently no browser supports HTTP/2 unencrypted.
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)
Run
curl --version
and look for HTTP2 on the Features list
Here you can find a list of Tools for debugging, testing and using HTTP/2.
Probably the easiest one from the command line is:
$ is-http2 www.cloudflare.com
But that requires npm install -g is-http2-cli
For testing using curl
you may need to compile it using the nghttp library, in macOS this can be done by using brew
you could use:
$ brew install curl --with-nghttp2
And then you could use what @daniel-stenberg suggests in his answer
$ curl -sI https://curl.haxx.se -o/dev/null -w '%{http_version}\n'
In where you will get a 2 if http2 is supported.
I used
curl -kvso /dev/null --http2 https://app.domain.com:443
which returned
...
> GET / HTTP/2
...
< HTTP/2 302
...
this is not checking if HTTP2 is supported, but check if HTTP2 actually works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With