Reputation: 7249
There are a lot of topics about the HTTP/2 protocol, but I wonder if there is a working website with this protocol.
I.e.
We can decide to use http://
or https://
, but how can we write a HTTP/2 request?
I am aware that this protocol depends on the server capability, but I can not find a way to check if a website, e.g. google.com
, has HTTP/2 support enabled.
As I can see in this picture, all modern browsers support this protocol. I have not seen any link that could look like a new generation protocol.
Are we using the HTTP/2 protocol without knowing or it is just a fairy tale?
Upvotes: 197
Views: 214616
Reputation: 13962
You can use the curl
command to find out if a particular website has HTTP/2 protocol support or not. In the following example, just replace https://www.cloudflare.com/
with the URL you want to check for HTTP/2 support:
% curl --http2 -sI https://www.cloudflare.com/ -o /dev/null -w '%{http_version}\n'
This command will display the HTTP version used by the server when connecting to the website (Thanks to @terryf82).
You can also use openssl
to make sure if the server uses ALPN (ALPN is a TLS extension that allows the application layer to negotiate which protocol should be performed over a secure connection. It is used to establish HTTP/2 connections without additional round trips.)
% openssl s_client -connect quora.com:443 -alpn h2 </dev/null 2>/dev/null | grep -i "ALPN"
No ALPN negotiated
% openssl s_client -connect stackoverflow.com:443 -alpn h2 </dev/null 2>/dev/null | grep -i "ALPN"
ALPN protocol: h2
Upvotes: 87
Reputation: 20239
You can just check it in: Chrome Dev Tool (F12) → Network → Protocol.
It will tell you the protocol used and the domain of each transfer.
http/1.1 = HTTP/1.1
h2 = HTTP/2
h3 = HTTP/3
Note: If you cannot see the Protocol column, just right-click on any header and check the "Protocol" label.
Upvotes: 338
Reputation: 699
You can use command
curl -vso /dev/null https://google.com 2>&1 | grep ALPN
The output is going to be either
* ALPN, offering h2 // Client is offering HTTP 2 protocol
* ALPN, offering http/1.1 // Client is also offering HTTP 1.1 protocol
* ALPN, server accepted to use h2 // Server said that it is going to use HTTP 2 protocol
Or
* ALPN, offering h2 // Client is offering HTTP 2 protocol
* ALPN, offering http/1.1 // Client is also offering HTTP 1.1 protocol
* ALPN, server accepted to use http/1.1 // Server said that it's going to use HTTP 1.1 protocol, even though client supports HTTP 2.0
You can see explanations are right in the quoted output after //
Upvotes: 6
Reputation: 960
This question has been answered already but I am going to answer this still.
Go to Chrome's Developer Tools
. You can open up the Developer tools in many ways like:
Network
tab by default if you use the keyboard combination.F12
on your keyboard to do the same.Three dots aka ellipsis -> More Tools -> Developer Tools
In the Name
column right-click and make sure Protocol
is checked. Now you can see the Protocol
Column where h2
refers to HTTP/2
and h3
refers to HTTP/3
in case you see them and http/1.1
refers to HTTP/1.1
.
You can see the Protocol
Column alternatively the following way:
Right-click the row that you see under the Name
column and the click on Header Options
and check Protocol
.
You can also check from here for free. An example is here: type in there https://google.com or your site with HTTPS protocol.
There is also a chrome browser extension that can help you. The ref link is here.
You can also use curl
command to check. This thread has an accepted answer for this.
You can use this command if you like CLI
curl -sI --http2 https://stackoverflow.com/ | grep -i "HTTP/2"
Upvotes: 18
Reputation: 4820
Solution using curl
command as the existing curl solution did not work well for me. curl
provides a switch --http2-prior-knowledge
which ensures a direct HTTP/2 request is sent without attempting a HTTP/1.1 upgrade request. Below examples can help understand the behavior in different cases:
Curl to Google which supports HTTP/2 - automatically HTTP/2 is chosen.
curl -Iks https://www.google.com/robots.txt
HTTP/2 200
accept-ranges: bytes
vary: Accept-Encoding
content-type: text/plain
content-length: 7199
cross-origin-resource-policy: cross-origin
date: Fri, 21 May 2021 13:39:02 GMT
expires: Fri, 21 May 2021 13:39:02 GMT
cache-control: private, max-age=0
Curl to my server which does not supports HTTP/2 - response states HTTP/1.1
curl -Iks https://myserver/reset
HTTP/1.1 502 Bad Gateway
connection: close
content-length: 0
Curl to my server with --http2
switch. Response still states HTTP/1.1
curl -Iks --http2 https://myserver/reset
HTTP/1.1 502 Bad Gateway
connection: close
content-length: 0
Curl to my server with --http2-prior-knowledge
. Note that no response is obtained.
curl -Iks --http2-prior-knowledge https://myserver/reset
If the above is executed with v
switch (verbose), the output would include the below line.
* http2 error: Remote peer returned unexpected data while we expected SETTINGS frame. Perhaps, peer does not support HTTP/2 properly.
Note:
k
is for insecure
- my server uses a self signed certificate. Not needed otherwise.I
is to send a HEAD
request and avoid noise in output.Upvotes: 7
Reputation: 52534
Open Dev Tools in Chrome using F12. Then go to the Network tab.
Right click on a row, select Header Options, and then select Protocol from the menu.
Upvotes: 38
Reputation: 868
You can also use a cool Chrome/Firefox extension called HTTP/2 and SPDY indicator to check the website protocol.
Upvotes: 4
Reputation: 5584
Open the browser development tools and switch to the network tab. There you'll see h2 if HTTP/2 is available.
Upvotes: 7
Reputation: 46090
HTTP/2 reuses the http:// and https:// schemes rather than use new ones.
All browsers only support HTTP/2 over https:// and part of the SSL/TLS negotiation is to communicate whether both sides support HTTP/2 and are willing to use it (using an extension to SSL/TLS called ALPN).
The advantage for this is you can just connect to a website and if your browser supports it, it will automatically negotiate HTTP/2, and if not it will automatically fall back to HTTP/1.1.
So to test for HTTP/2 support you can use the browser as Markus's suggests (make sure to add the Protocol column to the Network tab in Chrome for example).
Or you can use an online tester like https://tools.keycdn.com/http2-test
Or you can use a command line tool like openssl (assuming it's been built with ALPN support): openssl s_client -alpn h2 -connect www.example.com:443 -status
.
Most of the larger websites (e.g. Twitter, Facebook, Amazon, Stack Overflow) are using HTTP/2 now.
Upvotes: 41