使用curl7.33.0的--http2.0选项会导致不支持的协议。

7

我正在使用CentOS 6.2,需要在服务器请求中使用curl --http2.0命令,但是我安装的版本为7.19.6。在查看了http://curl.haxx.se/docs/manpage.html之后发现,--http2.0选项只支持curl 7.33.0版本及以上。为了解决这个问题,我按照http://www.linuxfromscratch.org/blfs/view/svn/basicnet/curl.html中的步骤,安装了curl 7.33.0版本。但是,在安装完毕后,我仍然无法使用该命令,出现curl(1):unsupported protocol错误。我检查了curl的版本,使用了curl --version命令,显示如下:

curl 7.33.0 (x86_64-unknown-linux-gnu) libcurl/7.33.0 OpenSSL/1.0.0 zlib/1.2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz 

我需要使用--http2.0,但是不知道如何实现。由于curl 7.19已安装,因此我重新安装了更高版本的curl,这是否会造成任何问题?

1个回答

6

正如Daniel在邮件列表中所解释的:

我的计划是基于nghttp2库(https://github.com/tatsuhiro-t/nghttp2)开展http2工作[...] 在libcurl术语中,HTTP2将作为一个“特性”开始,而不是作为一个单独的协议。

因此,首先需要手动安装nghttp2[1]。

然后,您需要在配置时明确启用HTTP2支持,使用--with-nghttp2参数:

./configure --with-nghttp2=/path/to/nghttp2/install/dir [...]

[1]: 写README的时候指出它在Ubuntu中没有打包,所以你需要自己构建编辑 请查找以下基本说明,以使用默认选项仅构建库(而不是命令行工具)。 要构建nghttp2,您首先需要安装其要求(如nghttp2文档页面上详细说明):
# To clone the nghttp2 Github repo
yum install git

# Build essentials
yum install gcc
yum install make
yum install automake
yum install libtool

# Required to build the library
yum install pkgconfig
yum install zlib-devel

完成后克隆存储库:

git clone https://github.com/tatsuhiro-t/nghttp2.git
cd nghttp2

按照 这里 的说明构建库:

autoreconf -i
automake
autoconf
# Note: I assume you want to deploy it under /usr/local
# Feel free to adapt to your needs!
./configure --prefix=/usr/local
make

然后部署它:
make install

如果一切顺利,您需要构建libcurl 7.33.0,并注意启用nghttp2,方法是使用./configure --with-nghttp2=/usr/local [...]附加内容 如果您想要额外构建应用程序(如nghttp等),则需要在构建nghttp2之前安装其他软件包。
yum install openssl-devel
yum install libevent-devel
yum install libxml2-devel
yum install jansson-devel

我无法安装它,你能给我提供一步一步的安装说明吗?因为我是 Linux 的新手用户...感谢您的支持。 - Mehul Thakkar
如有可能,请提供支持所需其他软件的说明。 - Mehul Thakkar
我已经编辑了我的问题,并附上了nghttp2库的构建说明。 - deltheil
autoreconf -i 给我报错:perl: warning: Setting locale failed. perl: warning: 请检查你的locale设置: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" 是否被支持并且安装在你的系统上。 perl: warning: Falling back to the standard locale ("C"). <br/> configure.ac:205: 警告: 在库中未找到宏“AM_PATH_XML2” autoreconf: /usr/bin/autoconf 失败,退出状态为: 1 - Mehul Thakkar
1
太好了!我又编辑了一次我的答案,并加入了可能需要的额外软件包(特别是libxml2-devel,我假设你已经安装了它来解决配置错误)。 - deltheil
是的,我已经预装了那个。 - Mehul Thakkar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接