curl 加上 –http2 可以支持 http2 协议,让我们看看 man 手册怎么说:
–http2
(HTTP) Tells curl to issue its requests using HTTP 2. This requires that the underlying libcurl was built to support it. (Added
in 7.33.0)
然而,在请求时加上 –http2 依然会报错
curl: (1) Unsupported protocol
根据 RFC 7540[注:1] ,需要本地添加 nghttp2 支持(CentOS 直接 yum/dnf 安装的没有用)
于是参考网络资料安装 nghttp2 [注:2], 并升级本地 curl 到新版本就可以支持了。
注1:https://www.rfc-editor.org/rfc/rfc7540.txt
注2:https://serversforhackers.com/video/curl-with-http2-support