8

I want to know if a request between a JavaScript Client and Node.js server is performed using HTTP1.x or HTTP2.

How I know in XMLHttpRequest, Chrome Console and Node.js what type of protocol is used ?

6
  • 2
    Are you asking how to do it programmatically or how to observe it? If later, then simply look in to Network tab of Dev tools browser and look for HTTP/1.1 or HTTP/2 in the request headers. You can also use curl. Commented Feb 21, 2019 at 16:58
  • Yes, how to observe it in browser dev tools and on client and server programmatically. Commented Feb 21, 2019 at 17:00
  • When the browser(client) and server both support HTTP/2 then it will be used for all calls from the browser. Can't you tell from your node js server? Commented Feb 21, 2019 at 17:07
  • I don't believe you can determine programmatically determine the HTTP/2 support on the browser by itself. NodeJS that information will be obtainable, however, but how to obtain it depends if you're using NodeJS's built in http server or if you're using a library like express. Commented Feb 21, 2019 at 17:10
  • 1
    See stackoverflow.com/questions/37829617/… for how to get the HTTP version in nodeJS using express. Commented Feb 21, 2019 at 17:39

1 Answer 1

15

Standard one: performance.timing.nextHopProtocol

Non standard implemetation: window.chrome.loadTimes().connectionInfo

You can check in network tab of dev tools where h2 represents HTTP2,

The Protocol column in the Network panel

When the Protocol column says h2 it means that the resource was sent with HTTP/2. The Protocol column is hidden by default. Right-click the table header and select Protocol to show it. See Show more information for an example.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.