Is there a shell command to see the headers of a HTTP request?
For example, I would like to know what the headers retrieved from
How can I do this?
In order to retrieve only the header, give this a try:
curl -I example.com
(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on a FTP or FILE file, curl displays the file size and last modification time only.
Use wget for instance
wget -O - -o /dev/null --save-headers www.example.com/test.php
You can do that with curl:
curl -i 'http://example.com/'
HTTP/1.0 302 Found Location: http://www.iana.org/domains/example/ Server: BigIP Connection: Keep-Alive Content-Length: 0
(for some reason, IANA decided to redirect example.com, result: no body)
curls manual page about the
(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...
Or you can use
The result is very similar to that produced by
curl -i 'http://example.com/' although it seems to return more headers.
200 OK Connection: close Date: Sun, 20 Mar 2011 19:08:58 GMT Server: Apache/2.2.3 (CentOS) Content-Length: 2945 Content-Type: text/html; charset=UTF-8 Last-Modified: Wed, 09 Feb 2011 17:13:15 GMT Client-Date: Sun, 20 Mar 2011 19:09:08 GMT Client-Peer: 22.214.171.124:80 Client-Response-Num: 1
You can see them with curl.
curl --include to include the response-headers in the top of the response-body.
curl --verbose to see it all including SSL certificate exchanging the handshake (plus other debug information)
if the request itself and neither the response-body are not of you concern, just use
curl --head --no-check-certificate --url "https://example.com".
You can download gnu
curl already pre-compiled for the most platforms.
curl is quite the useful too, especially if you would like to pipe or redirect the result inside a script.
*for example: https://superuser.com/a/1007898/429721