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 --compressed asks for gzip and decodes it for you

Curl
~/tips/tip-curl-compressed-accept-encoding

curl -s --compressed -D - -o /dev/null https://example.com/ | grep -i '^content-encoding'

Requests compressed content and shows from the headers whether the server provides it.

I use this to check whether a server compresses its responses at all.

curl -s --compressed -D - -o /dev/null https://example.com/ | grep -i '^content-encoding'

--compressed sends an Accept-Encoding header with the encodings your curl supports and decompresses the answer, so you read plain text. -D - prints the response headers to standard output and -o /dev/null drops the body. A content-encoding: gzip line means the server compressed it. Which encodings are offered depends on the build: gzip needs zlib, and brotli and zstd are only present in some builds. Run curl -V to see the list. Without --compressed a server that compresses anyway would hand you unreadable bytes when you add Accept-Encoding by hand.

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