HTTP response headers show what a URL actually returned before the response body, retry logic, or application parsing hides the details. A quick header check is often enough to confirm the status line, content type, redirects, cache policy, cookies, and other metadata that explains why a request behaved the way it did.

For a normal GET request, curl can place the received header block before the body with -i, the short form of the current --show-headers option. The older --include long option remains accepted, and --dump-header writes the same received headers to a file when the body should stay separate.

Header inspection is different from sending a HEAD request. --head or -I asks the server for metadata without a response body, which can be rejected or handled differently from GET. Use the response-header options below when the question is which headers a normal request received, especially after redirects or authenticated API calls. Saved header files can contain cookies, redirect targets, and other sensitive values, so redact them before sharing.

Steps to show HTTP response headers with cURL:

  1. Run a normal request with -i to print the response headers before the response body.
    $ curl --silent --show-error -i https://api.example.net/headers
    HTTP/1.1 200 OK
    Server: ExampleHTTP/1.0
    Date: Sat, 06 Jun 2026 00:00:00 GMT
    Content-Type: application/json
    Cache-Control: no-store
    X-Request-Trace: sg-response-header-demo
    Content-Length: 53
    
    {"status":"ready","trace":"sg-response-header-demo"}

    -i is the short form of --show-headers. Current curl documentation names the long option --show-headers, while older documentation and existing scripts may still use --include.

  2. Add --location when the URL can redirect before the final response.
    $ curl --silent --show-error -i --location https://api.example.net/redirect
    HTTP/1.1 302 Found
    Server: ExampleHTTP/1.0
    Date: Sat, 06 Jun 2026 00:00:00 GMT
    Location: /headers
    Cache-Control: no-store
    Content-Length: 0
    
    HTTP/1.1 200 OK
    Server: ExampleHTTP/1.0
    Date: Sat, 06 Jun 2026 00:00:00 GMT
    Content-Type: application/json
    Cache-Control: no-store
    X-Request-Trace: sg-response-header-demo
    Content-Length: 53
    
    {"status":"ready","trace":"sg-response-header-demo"}

    With --location, curl shows each response block in order, so the last header block is the final response after the redirect chain.

  3. Write the response headers to a separate file with --dump-header when the body should stay out of the terminal.
    $ curl --silent --show-error --dump-header response-headers.txt --output /dev/null https://api.example.net/headers

    --output /dev/null discards the response body while --dump-header saves only the received headers.

  4. Read the saved header file to confirm the exact headers that curl received.
    $ cat response-headers.txt
    HTTP/1.1 200 OK
    Server: ExampleHTTP/1.0
    Date: Sat, 06 Jun 2026 00:00:00 GMT
    Content-Type: application/json
    Cache-Control: no-store
    X-Request-Trace: sg-response-header-demo
    Content-Length: 53

    Header files from authenticated requests can contain cookies, redirect targets, and other sensitive values, so redact them before sharing the file.

  5. Remove the temporary header file after the check is complete.
    $ rm response-headers.txt