Closed paya-cz closed 2 years ago
From the docs:
This option requires Node.js 15.10.0 or newer as HTTP/2 support on older Node.js versions is very buggy.
I would also recommend trying Got v12 beta, which will be out in a final version soon: https://github.com/sindresorhus/got/releases/tag/v12.0.0-beta.4
@sindresorhus I have tried accessing https://nghttp2.org/httpbin/anything via Chromium and it returns Via
header as 1.1
, yet the Chromium network tab clearly shows the protocol as h2
. I suspect the nghtt2.org
server has a buggy HTTP2 detector (perhaps they started using reverse proxy?). The http2.pro
server I suggested seems to detect H2 properly. So I think this has nothing to do with Got, it's just that the example in Got documentation no longer shows what it's meant to show.
It uses HTTP/2 but the proxy server is called 1.1 nghttpx
, probably because the request is being converted to HTTP/1.1 server-side. The example is just outdated, we can check socket.alpnProtocol
instead.
Describe the bug
Unable to confirm Got works with HTTP2 by following documented example.
Actual behavior
Console prints:
Expected behavior
Console prints:
Code to reproduce
Code from: https://github.com/sindresorhus/got/tree/v11.8.2#http2
Fix
Use a different server: