bn4*_*n4t 9 curl unit-testing http2
我目前正在编写单元测试,以检查是否http/2受支持。
是否有一个curl单线可检查是否http/2受支持并输出易于解析的响应?
Dan*_*erg 20
HTTP/2 supported:
$ curl -sI https://curl.haxx.se -o/dev/null -w '%{http_version}\n'
2
Run Code Online (Sandbox Code Playgroud)
HTTP/2 not supported (instead serving 1.1 in this case):
$ curl -sI http://curl.haxx.se -o/dev/null -w '%{http_version}\n'
1.1
Run Code Online (Sandbox Code Playgroud)
(curl 7.50.0 or later is required for this command line to work)
跑
curl --version
Run Code Online (Sandbox Code Playgroud)
并在功能列表中查找 HTTP2
在这里您可以找到用于调试、测试和使用 HTTP/2 的工具列表。
命令行中最简单的方法可能是:
$ is-http2 www.cloudflare.com
Run Code Online (Sandbox Code Playgroud)
但这需要 npm install -g is-http2-cli
对于使用测试,curl您可能需要使用nghttp库编译它,在 macOS 中,这可以通过使用来完成,brew您可以使用:
$ brew install curl --with-nghttp2
Run Code Online (Sandbox Code Playgroud)
然后你可以使用@daniel-stenberg 在他的回答中提出的建议
$ curl -sI https://curl.haxx.se -o/dev/null -w '%{http_version}\n'
Run Code Online (Sandbox Code Playgroud)
如果支持 http2,您将在其中获得 2。
| 归档时间: |
|
| 查看次数: |
6094 次 |
| 最近记录: |