我已经按照这里的步骤操作过,但仍然在使用curl --http2
选项时出现不支持的协议
。同样地,将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)
在执行make
和sudo 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
然后我按照这里的建议行事,需要安装 OpenSSL 1.0.2或更高版本。我将其安装在 /opt/openssl 中,并重新配置:
./configure --with-nghttp2=/usr/local --with-ssl=/opt/openssl/lib
make
和sudo make install
之后,所有问题仍然存在。令人惊奇的是,curl --version
仍然返回与上面相同的信息,且OpenSSL/1.0.1f尚未升级。
任何能够让我成功使用--http2
选项的帮助将不胜感激。
./configure
之前加上sudo
命令。如果没有使用sudo
,我的安装无法正常工作。 - Curiosoautoreconf -i automake autoconf sudo ./configure --prefix=/usr/local sudo make sudo make install LD_LIBRARY_PATH=/usr/local/lib curl --http2 http://google.com curl: (1) 不支持的协议
- Jeff Silvermanotool -L `which curl`
。 - CodeGroover