curl
Headers
Set and inspect request and response headers.
By EZ4Code Team
headerverbose
Code
# Set request headers
curl https://api.example.com/data \
-H "Authorization: Bearer TOKEN" \
-H "Accept: application/json" \
-H "User-Agent: MyApp/1.0"
# Inspect response headers only
curl -I https://example.com
# Headers + body
curl -i https://example.com
# Save response headers to a file
curl -D headers.txt https://example.com -o body.htmlExplanation
The -H flag adds a request header and can be repeated to send several. -I fetches headers only via a HEAD request, while -i prints headers above the body. -D writes response headers to a file, useful for inspecting Set-Cookie or cache headers without polluting stdout.