Install Curl with HTTP2 support on Ubuntu



Published: 2019-09-26 07:36:40 +0000
Categories: BASH,

Language

BASH

Description

Although the version of curl in the Ubuntu repos is sufficiently recent to support HTTP/2, Ubuntu have compiled the packages without nghttp2 support, so if you try and use --http2 you'll probably receive the output curl: (1) Unsupported protocol

This snippet details how to install deps, and then compile curl with http/2 support - it can then be installed alongside, or over the top of the existing curl (alongside is better IMO).

Snippet

sudo apt-get nghttp2 libnghttp2-dev libssl-dev
wget https://curl.haxx.se/download/curl-7.66.0.tar.gz
tar xzf curl-7.66.0.tar.gz
cd curl-7.66.0/
./configure --with-nghttp2 --with-ssl
make

# If you want to install alongside, and only for you
echo "alias curl-h2=\"$PWD/src/curl --http2 --http2-prior-knowledge\"" >> ~/.bashrc

# Or, alongside but for everyone
echo "alias curl-h2=\"$PWD/src/curl --http2 --http2-prior-knowledge\"" | sudo tee -a /etc/profile

# Or to install over the top 
# (will install as curl and you will need to specify --http2 --http2-prior-knowledge )
sudo make install

Usage Example

# Assuming an alias was created
curl-h2 "https://www.bentasker.co.uk" -v -o/dev/null

# If not, then
curl --http2 --http2-prior-knowledge "https://www.bentasker.co.uk" -v -o/dev/null

Keywords

curl, http2, http/2, compile, install, ubuntu, http, cli,

Latest Posts


Copyright © 2022 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk, http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion and http://snippets.bentasker.i2p
hit counter