brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl --http2 and --http1.1 show which protocol a server really speaks

Curl
~/tips/tip-curl-compare-http-versions

curl -sI --http2 -o /dev/null -w '%{http_version}\n' https://example.com/

Shows the negotiated HTTP version and lets you force an older one for comparison.

A proxy or server that mishandles HTTP/2 is easier to spot when you ask for both versions.

curl -sI --http2 -o /dev/null -w '%{http_version}\n' https://example.com/
curl -sI --http1.1 -o /dev/null -w '%{http_version}\n' https://example.com/

The -w variable prints 2 when the server answered over HTTP/2 and 1.1 otherwise. Over HTTPS curl negotiates the version through ALPN, and builds with nghttp2 already try HTTP/2 by default, so --http1.1 is the flag that changes things. The flags also work with -v, which prints every request header. --http3 needs a build with HTTP/3 support. Compare the status and headers of both runs when a site behaves differently per version.

Further reading: curl manual

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link