Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP2 with CURL gives "Unsupported Protocol"

Tags:

Having already followed the steps from here, I still have Unsupported Protocol when using curl --http2 option. Similarly, setting the CURLOPT_HTTP_VERSION to CURL_HTTP_VERSION_2_0 results in the program communicating using HTTP/1.1, not HTTP/2.

Platform: Ubuntu 15.04 on VMware Player 7.

I have installed nghttp2-1.0.4 with --prefix=/usr/local, hence the libnghttp2.* is located in /usr/local/lib.

This is the code to configure curl-7.43.0:

./configure --with-nghttp2=/usr/local

The result shows that HTTP2 is enabled:

    HTTP2 support:    enabled (nghttp2)

After make and sudo make install, the following returns Unsupported Protocol:

curl --http2 https://http2.akamai.com

The curl version doesn't show nghttp2 is supported:

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

Then I followed the advise from here, that I need to have OpenSSL 1.0.2 or higher. Having installed that in /opt/openssl, I reconfigured:

./configure --with-nghttp2=/usr/local --with-ssl=/opt/openssl/lib

After make and sudo make install, all problems remain the same. Strangely enough, the curl --version still returns the same information as above, with OpenSSL/1.0.1f not yet upgraded.

Any help that allows me to successfully use the --http2 option is greatly appreciated.

like image 776
Curioso Avatar asked Jun 25 '15 03:06

Curioso


People also ask

Does curl support HTTP 2?

curl supports http2 over standard TCP via the Upgrade: header. If you do an HTTP request and ask for HTTP 2, curl will ask the server to update the connection to http2 if possible.

Which curl version supports http2?

Since 7.47. 0, the curl tool enables HTTP/2 by default for HTTPS connections.

How do I know if my curl supports http2?

Running curl -V will show if your version of curl supports it. If you by some chance already know that your server speaks HTTP/2 (for example, within your own controlled environment where you know exactly what runs in your machines) you can shortcut the HTTP/2 "negotiation" with --http2-prior-knowledge .


2 Answers

Apparently you are not linking with the right version of curl, at least at runtime. That's what the output libcurl/7.38.0 means. Mine has a higher version number there. Try

LD_LIBRARY_PATH=/usr/local/lib curl <whatever> 

as your command. Or just to be sure:

ldd `which curl` 

and pay attention to the dependencies that appear listed.

like image 156
dsign Avatar answered Sep 19 '22 11:09

dsign


This one really helps me set it up properly

  • git clone https://github.com/tatsuhiro-t/nghttp2.git
  • cd nghttp2
  • autoreconf -i
  • automake
  • autoconf
  • ./configure
  • make
  • sudo make install

    • cd ~
    • sudo apt-get build-dep curl
    • wget http://curl.haxx.se/download/curl-7.46.0.tar.bz2
    • tar -xvjf curl-7.46.0.tar.bz2
    • cd curl-7.46.0
    • ./configure --with-nghttp2=/usr/local --with-ssl
    • make
    • sudo make install
    • sudo ldconfig (to verify) curl --http2 -k -vvv -XPOST https://ip/ https://serversforhackers.com/c/curl-with-http2-support
like image 33
khushbu Avatar answered Sep 18 '22 11:09

khushbu