Skip to content
shellmap

Get HTTP response headers

Inspect just the response headers of a URL — useful for debugging redirects, caching, CORS, and TLS.

How to get http response headers in each shell

Bashunix
curl -sSI https://example.com
Zshunix
curl -sSI https://example.com
Fishunix
curl -sSI https://example.com
PowerShellwindows
(Invoke-WebRequest -Method Head -Uri https://example.com).Headers

`.Headers` is a `System.Collections.Generic.Dictionary[string,string]` — case-INSENSITIVE keys (`$resp.Headers["content-type"]` and `$resp.Headers["Content-Type"]` return the same value). Note `Invoke-RestMethod` does NOT expose `.Headers` directly; use `Invoke-WebRequest` for header inspection.

cmd.exewindows
curl -sSI https://example.com

cmd ships `curl.exe` in System32 since Win10 1803. For older Windows shell out to PowerShell.

Equivalents listed for Bash, Zsh, Fish, PowerShell, cmd.exe.

Gotchas & notes

  • `curl -I` issues an HTTP **HEAD** request. Some servers (especially CDN edges + load balancers) respond differently to HEAD vs GET — a 405 on HEAD doesn't mean the resource is missing. Use `curl -sS -D - -o /dev/null URL` to dump headers from a GET (response body discarded). The `-D -` writes the response header block to stdout.
  • Capture the headers across a redirect chain: `curl -sSLI URL` (`-L` follows redirects, `-I` prints headers for each hop). Output is multiple HTTP/1.1 200/301/302 blocks separated by blank lines — read top-to-bottom to trace the chain.
  • HTTP headers are case-INSENSITIVE per RFC 7230 §3.2 but tools differ on how they preserve case. `curl` echoes the server's case (`Content-Type:`). PowerShell `Invoke-WebRequest` normalizes via .NET's case-insensitive dictionary. Don't key parsing logic on case (`grep -i` not `grep`, or PowerShell `$h["content-type"]` works regardless of returned case).
  • For one specific header without grep noise: `curl -sSI URL | awk -F': ' 'tolower($1)=="content-type"{print $2}'`. PowerShell: `(iwr -Method Head URL).Headers."Content-Type"`. Beware multi-value headers (Set-Cookie, Via) — they may appear on multiple lines in curl output but coalesce in some clients.

Related commands

Related tasks