根据这个链接 https://curl.haxx.se/docs/http2.html,
自7.47.0版本以来,curl工具默认启用HTTPS连接的HTTP/2协议。
通过homebrew安装最新版本并检查:
自7.47.0版本以来,curl工具默认启用HTTPS连接的HTTP/2协议。
通过homebrew安装最新版本并检查:
curl --version
curl 7.54.1 (x86_64-apple-darwin15.6.0) libcurl/7.54.1 SecureTransport zlib/1.2.5
但当我在启用HTTP2的URL上运行curl
时(例如使用https://tools.keycdn.com/http2-test进行测试),出现以下情况:
curl -I http://www.google.co.uk
HTTP/1.1 200 OK
并且
curl --http2 -v http://www.google.co.uk
curl: (1) Unsupported protocol
你知道为什么它使用的是HTTP/1.1而不是HTTP/2吗?
SSLSetALPNProtocols
。它可在iOS 11+和macOS 10.13+上使用。 - Guillaume Algis