【问题标题】:HTTP2 with CURL gives "Unsupported Protocol"带有 CURL 的 HTTP2 给出“不支持的协议”
【发布时间】:2015-09-11 11:54:53
【问题描述】:

已经按照here 的步骤进行操作,当使用 curl --http2 选项时,我仍然有 Unsupported Protocol。同样,将CURLOPT_HTTP_VERSION 设置为CURL_HTTP_VERSION_2_0 会导致程序使用HTTP/1.1,而不是HTTP/2 进行通信。

平台:VMware Player 7 上的 Ubuntu 15.04。

我已经用--prefix=/usr/local 安装了nghttp2-1.0.4,因此libnghttp2.* 位于/usr/local/lib

这是配置 curl-7.43.0 的代码:

./configure --with-nghttp2=/usr/local

结果显示启用了HTTP2:

    HTTP2 support:    enabled (nghttp2)

makesudo make install之后,以下返回Unsupported Protocol

curl --http2 https://http2.akamai.com

curl 版本不显示支持 nghttp2:

curl 7.43.0 (i686-pc-linux-gnu) libcurl/7.38.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API SPNEGO NTLM NTLM_WB SSL libz TLS-SRP

然后我听从了here 的建议,我需要使用 OpenSSL 1.0.2 或更高版本。在 /opt/openssl 中安装后,我重新配置:

./configure --with-nghttp2=/usr/local --with-ssl=/opt/openssl/lib

makesudo make install 之后,所有问题都保持不变。奇怪的是,curl --version 仍然返回与上面相同的信息,OpenSSL/1.0.1f 尚未升级。

非常感谢任何能让我成功使用--http2 选项的帮助。

【问题讨论】:

    标签: curl http2


    【解决方案1】:

    显然你没有链接到正确版本的 curl,至少在运行时是这样。这就是输出 libcurl/7.38.0 的含义。我的那里有更高的版本号。试试

    LD_LIBRARY_PATH=/usr/local/lib curl <whatever> 
    

    作为您的命令。或者只是为了确定:

    ldd `which curl` 
    

    并注意列出的依赖项。

    【讨论】:

    • 上面第二条命令显示我仍在使用默认库/lib/i386-liux-gnu。将库路径设置为上面的第一个代码解决了这个问题。 Curl 现在说的是 http2。谢谢!
    • 按照here 的建议,在./configure 之前命令sudo。没有sudo,我的就不行了。
    • 我还是有问题。 ~~~~ autoreconf -i automake autoconf sudo ./configure --prefix=/usr/local sudo make sudo make install LD_LIBRARY_PATH=/usr/local/lib curl --http2 google.com curl: (1) 不支持的协议~~ ~~
    • 对于mac os x,它将是otool -L `which curl`
    【解决方案2】:

    这个真的帮助我正确设置它

    【讨论】:

    • 非常感谢,它帮助我今天在 Debian 8 上安装了支持 http2 的 curl 7.46。
    【解决方案3】:

    我发现curl 7.53.1 for Windows 这个工具对于测试http2 请求非常有用。 它为 Windows 预编译了 curl,支持 OpenSSL、ngttp2、zlib 和 IPv6。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-15
      • 2015-12-19
      • 1970-01-01
      • 2023-04-10
      • 2015-10-20
      • 1970-01-01
      • 2017-09-14
      • 1970-01-01
      相关资源
      最近更新 更多