How to display request headers with curl

September 13, 2022 No comments curl request headers

1. Introduction

In this short, article we will present how to display HTTP request headers with the curl command line tool.

2. Display request headers with curl

To display request headers we could use the following command:

curl -s -D - -o /dev/null

The parameters:

  • -s - stands for silent mode,
  • -D - dump headers to a file but - send it to standard output (console),
  • -o /dev/null - redirect output to /dev/null - to ignore response body (we only want headers).

Note that on Windows you need to use -o NULL instead of -o /dev/null:

curl -sD - -o NULL

The output:

HTTP/2 301 
content-type: text/html; charset=UTF-8
date: Tue, 13 Sep 2022 17:38:57 GMT
expires: Tue, 13 Sep 2022 17:38:57 GMT
cache-control: private, max-age=2592000
server: gws
content-length: 220
x-xss-protection: 0
x-frame-options: SAMEORIGIN
p3p: CP="This is not a P3P policy! See for more info."
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"

3. Conclusion

In this short article we presented how to display request headers with curl, if you searching want to show also response headers check the following link:

Display request and response headers with cURL

{{ message }}

{{ 'Comments are closed.' | trans }}