前言
对于测试网站http3功能的时候,我们一般情况下喜欢用curl这个程序进行测试。但是当我们使用WINDOWS自带的curl的时候,会出现以下的报错
C:\Users\q2019>curl -I --http3 https://example.com
curl: option --http3: the installed libcurl version does not support this
curl: try 'curl --help' for more information
这是因为WINDOWS自带的curl是不支持http3的,这篇文章就会讲解如何对这个报错进行处理。
解决方案
首先前往下载一个第三方编译的Curl(我等会会说明为什么不用官方编译的版本)
https://github.com/stunnel/static-curl/releases/tag/8.17.0
选择对应版本,下载完后进行解压,解压出来的文件如下图

在当前的目录下执行powershell,运行curl(命令如下),可以看到已经成功了
./curl -I --http3 https://example.com -v

如果有需求的话,可以在系统的环境变量中添加当前路径,从而在调用中覆盖掉windows系统默认的curl
附录
为什么不用官方的curl?这是因为使用官方的curl的话,会报如下的错误
C:\Users\q2019>curl -I --http3 https://example.com curl: option --http3: the installed libcurl version does not support this curl: try 'curl --help' for more informatio
这是因为官方的curl是用win64-mingw + LibreSSL编译,LibreSSL的构建常常是没有带QUIC(HTTP3)的,而这样子会导致Curl的QUIC无法正确实现。这是官方关于这个问题的说明。
https://curl.se/docs/http3.html
所以本文章使用的是一个第三方编译的curl。