Curl:单行测试 http/2 支持 [英] Curl: one-liner to test http/2 support

查看:30
本文介绍了Curl:单行测试 http/2 支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个单元测试来检查是否支持 http/2.

I'm currently writing an unit test to check if http/2 is supported.

是否有一个 curl 单行代码来检查是否支持 http/2 并输出一个易于解析的响应?

Is there a curl one-liner which checks if http/2 is supported and outputs a response that is easy to parse?

推荐答案

HTTP/2 支持:

$ curl -sI https://curl.haxx.se -o/dev/null -w '%{http_version}\n'
2

不支持 HTTP/2(在这种情况下提供 1.1):

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

(此命令行需要 curl 7.50.0 或更高版本)

(curl 7.50.0 or later is required for this command line to work)

这篇关于Curl:单行测试 http/2 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆