Get header information with cURL

There are many online tools where you can test your website’s headers. But there is a simply way to check the headers for one site with a local tool – cURL. cURL (Client URL) is a tool for transferring information through various protocols.

In our case, we will use it to get the headers for a specific site. The command is:

# curl -L -I domain.com
-L, --location	- cURL will follow any redirections
-I, --head	- cURL will get only the headers of the document

An example for our domain name is presented below. You see that the tool is getting only the headers and it also follows the redirection from plothost.com to https://www.plothost.com

root@web [~]# curl -L -I plothost.com
HTTP/1.1 301 Moved Permanently
Date: Wed, 13 May 2020 17:14:14 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Location: https://www.plothost.com/
Cache-Control: max-age=3600
Expires: Wed, 13 May 2020 18:14:14 GMT
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 200 OK
Date: Wed, 13 May 2020 17:14:15 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Last-Modified: Wed, 13 May 2020 16:43:54 GMT
ETag: "be9b-5a58a49253bdc"
Accept-Ranges: bytes
Content-Length: 48795
Cache-Control: max-age=10800, must-revalidate, public
Expires: Wed, 13 May 2020 17:43:54 GMT
Vary: Accept-Encoding,Cookie
Connection: keep-alive
Set-Cookie: HttpOnly;Secure
X-XSS-Protection: 1; mode=block
Referrer-Policy: no-referrer-when-downgrade
Expect-CT: enforce;max-age=30; report-uri https://plothost.report-uri.io/r/default/ct/enforce
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
Feature-Policy: accelerometer none;ambient-light-sensor none;autoplay none;camera none;geolocation none;gyroscope none;magnetometer none;microphone none;midi none;usb none;vibrate none;wake-lock none;xr-spatial-tracking none
Access-Control-Allow-Origin: *
Pragma: public
Content-Type: text/html; charset=UTF-8

root@web [~]#

Resources:

cURL man page

Leave a Reply