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 -H 'Accept:' removes a default header instead of setting one

Curl
~/tips/tip-curl-header-remove-default

curl -v -H 'User-Agent:' -H 'Accept:' -H 'X-Empty;' https://example.com/

Strips a header curl adds by default or sends one with an empty value.

curl adds headers like `User-Agent` and `Accept` on its own, and sometimes a test needs a request without them.

curl -v -H 'User-Agent:' -H 'Accept:' -H 'X-Empty;' https://example.com/

A header name followed by a colon and no value removes the header curl would normally send. A name followed by a semicolon sends the header with an empty value, so X-Empty; goes out as X-Empty:. With -v the lines that start with > are the request, which shows the result. Removing Host is possible too, but the server will most likely refuse the request.

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