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 https://google.com
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 https://www.google.com
The output:
HTTP/2 301
location: https://www.google.com/
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 g.co/p3phelp 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:
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}