cURL is not working with nghttp2
Asked Answered
C

2

2

I want to use http/2 with cURL. First I got an error when I tried this curl --http2 https://http2.akamai.com/ - "Protocol not supported". I installed nghttp2 and reinstalled cURL like it is described here. The error is gone and I can get data with the curl --http2 now. But the page https://http2.akamai.com/ tells me "This browser is not HTTP/2 enabled", while in chrome or directly via nghttp2 it says "You are using HTTP/2 right now!".

I'm using mac os x and installed all dependencies in the latest versions via homebrew. The curl sources (7.41) I downloaded here.

Chantry answered 20/4, 2015 at 22:13 Comment(0)
M
5

You're probably not running the newly built curl, or your new curl build is using the previous libcurl install. Invoke 'curl --version' and make sure it lists "HTTP2" as supported (included in Features).

You also need to make sure you build curl with an TLS library version that has support for ALPN (for HTTP/2 over TLS). If you build with openssl, you need version 1.0.2 (or later).

I just tried now on https://http2.akamai.com/ and it says "You are using HTTP/2 right now!" just fine when I try my curl build on it like this:

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

You can view the verbose output and you should see the ALPN offer and what protocol curl and the server agree on using.

Martian answered 21/4, 2015 at 6:29 Comment(4)
Yes, HTTP2 is listed as a feature. Here is the complete output: localhost:~ svenkeinath$ curl --version curl 7.41.0 (x86_64-apple-darwin14.3.0) libcurl/7.41.0 OpenSSL/0.9.8zd zlib/1.2.5 nghttp2/0.7.7 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: IPv6 Largefile NTLM NTLM_WB SSL libz HTTP2 UnixSockets Chantry
Yes :) Thank you! Rebuilding cURL with ./configure --with-ssl=/usr/local/Cellar/openssl/1.0.2a-1/ did the trick.Chantry
so....what do you do if you installed http2 c library and curl doesn't show the http2 protocol as being available?Swearword
I'd need more details. I recommend taking your issue to the curl-library list and we can work it out there.Martian
C
0

The page is probably whitelisted for particular browsers that are HTTP/2 enabled, so it's returning a static content because it doesn't recognize the cURL one. You can set your user agent to pretend that you're Chrome, e.g.

curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/41.0.742.112 Safari/534.30" --http2 https://http2.akamai.com/
Coverley answered 20/4, 2015 at 22:18 Comment(3)
I accessed with a UA from an old Motorola Razor and it worked fine:MOT-V9mm/00.62 UP.Browser/6.2.3.4.c.1.123 (GUI) MMP/2.0Subdual
No, none of them worked. It's not only a problem with this particular page - I also tried it with twitter and some others.Chantry
What I was saying is it has nothing to do with the user agent. I switched the UA in fireFox turned off JavaScript and it still was HTTP2 compliant.Subdual

© 2022 - 2024 — McMap. All rights reserved.