How to enable the curl command HTTP2 support
When we directly use curl to request an https page, the default response of HTTP1.1 is displayed by default. Now there are more and more websites using HTTP2 and more mature technologies. How to enable the curl command to Support HTTP 2 becomes a problem.
curl -I https://nghttp2.org/
When we try to use the http2 parameter, a "curl: (1) Unsupported protocol" error is returned:
curl --http2 -I https://nghttp2.org/
Run the following command to view the curl version:
curl --version
We can see that the current curl version and supported protocols and features do not support HTTP2.
Enable the curl command HTTP2 to support Compilation and installation of nghttp2
To enable curl to support HTTP2, We need to install nghttp2 (C language library of http2 ):
# Install the compilation tool sudo apt-get install git g ++ make binutils autoconf automake autotools-dev libtool pkg-config \ zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson- dev \ libjemalloc-dev cython python3-dev python-setuptools # compile and install nghttp2git clone https://github.com/tatsuhiro-t/nghttp2.gitcd nghttp2autoreconf-iautomakeautoconf. /configuremakesudo make install
Upgrade curl
cd ~sudo apt-get build-dep curlwget http://curl.haxx.se/download/curl-7.46.0.tar.bz2tar -xvjf curl-7.46.0.tar.bz2cd curl-7.46.0./configure --with-nghttp2=/usr/local --with-sslsudo make && make installecho '/usr/local/lib' > /etc/ld.so.conf.d/local.confldconfig
After the version is upgraded, the HTTP2 feature is added to the feature when we view the curl version. Now the-http2 parameter can be used normally:
curl --http2 -I https://nghttp2.org
Test curl with http2
Run the following command to test the winclient homepage:
curl --http2 -I https://www.winclient.cn
The returned results are as follows:
Curl usage: Get the header and status code of the website
Curl and wget advanced use of Linux tools
Ubuntu users install the download tool cURL 7.36.0
Linux curl
Sharing of Curl usage and common functions in Unix
Curl command
This article permanently updates the link address: