当我们直接使用 curl 去请求一个 https 页面时,默认可以看到其默认返回的是 HTTP1.1 的 response。现在使用 HTTP2 的网站越来越多,技术也越来越成熟,如何启用 curl 命令 HTTP 2 支持就成为了一个问题。
curl -I https://nghttp2.org/
当我们试图用 http2 参数时,会返回一个未支持协议的「curl: (1) Unsupported protocol」错误:
curl --http2 -I https://nghttp2.org/
使用如下命令我们可以看到 curl 版本:
curl --version