How to know if a request is performed using HTTP 1.x or HTTP2
Asked Answered
B

1

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 ?

Berna answered 21/2, 2019 at 16:54 Comment(6)
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.Islet
Yes, how to observe it in browser dev tools and on client and server programmatically.Berna
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?Islet
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.Grilse
Yes, I am using express. for example in node console I can see this output: GET /api/students/5c11dc780c9da0001640c39d 200 359.665 ms - 11424 , is it possible that we can display protocol used also ?Berna
See #37830117 for how to get the HTTP version in nodeJS using express.Grilse
O
12

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.

Offside answered 21/2, 2019 at 17:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.