已经按照此处Unsupported Protocol的步骤操作,使用 curl--http2选项时我仍然有。同样,将 设置为CURLOPT_HTTP_VERSION会CURL_HTTP_VERSION_2_0导致程序使用 HTTP/1.1 而不是 HTTP/2 进行通信。
平台:VMware Player 7 上的 Ubuntu 15.04。
我已经安装了 nghttp2-1.0.4 --prefix=/usr/local,因此 libnghttp2.* 位于/usr/local/lib.
这是配置 curl-7.43.0 的代码:
./configure --with-nghttp2=/usr/local
结果显示启用了 HTTP2:
HTTP2 support: enabled (nghttp2)
在makeand之后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非常感谢任何让我成功使用该选项的帮助。