How to enable the curl command HTTP2 support

Source: Internet
Author: User
Tags webp http 2

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.