其他分享
首页 > 其他分享> > Curl支持HTTP2

Curl支持HTTP2

作者:互联网

Curl支持HTTP2

一般情况下,都是利用系统的apt-get、yum来进行CURL库的安装。但是,在安装过程中,并支持http2协议。所以,有时候需要重新进行自编译。

curl各个版本的下载地址

https://curl.se/download/

重新自编译安装curl库

apt-get remove curl
apt-get install -y nghttp2
apt-get install -y libnghttp2-dev
apt-get install -y libssl-dev
./configure --with-nghttp2 --prefix=/usr/local --with-ssl --enable-versioned-symbols
echo ‘/usr/local/lib’ >> /etc/ld.so.conf.d/local.conf
ldconfig

在执行完 ./configure 后,注意最后的输出文档

PSL: no (libpsl not found)
Alt-svc: no (–enable-alt-svc)
HTTP2: enabled (nghttp2)
HTTP3: disabled (–with-ngtcp2, --with-quiche)
ESNI: no (–enable-esni)
Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP
Features: SSL IPv6 UnixSockets libz AsynchDNS NTLM NTLM_WB TLS-SRP HTTP2 HTTPS-proxy

如果 HTTP2是enable,说明正常。否则就是nghttp2 或者 libnghttp2-dev 出现问题,请解决之后再继续变异。

另外

./configure --with-nghttp2 --prefix=/usr/local --with-ssl --enable-versioned-symbols

中的 --enable-versioned-symbols 是用于其它软件进行版本查询。否则出现错误

/usr/local/lib/libcurl.so.4: no version information available

安装完之后,使用命令 curl --version 查看信息。

curl 7.67.0 (x86_64-pc-linux-gnu) libcurl/7.67.0 OpenSSL/1.0.2g zlib/1.2.8 nghttp2/1.7.1
Release-Date: 2019-11-06
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

在Features 中出现http2,说明curl已经支持http2协议

标签:enable,--,支持,nghttp2,HTTP2,Curl,local,curl
来源: https://blog.csdn.net/raycuizm/article/details/120335795