Share via:

Sending a HEAD Request From cURL

How to perform a simple HEAD request with cURL

24 views

Edited: 2019-11-09 04:23

Sending a HTTP HEAD request works similar to sending a GET request. The difference is that the server should only return the response headers of the requested page, leaving the response body empty.

This is useful when determining if a page has been updated, as it avoids downloading the entire body, and saves bandwidth for both the client and the server.

To send a HTTP HEAD request with cURL we can use the --HEAD option:

curl --HEAD http://beamtic.com/Examples/ip.php

Note. "-I" can also be used instead of "--HEAD".

Result:

HTTP/2 200 
date: Sat, 09 Nov 2019 03:43:23 GMT
server: Apache/2.4.29 (Ubuntu)
x-content-type-options: nosniff
x-powered-by: Doorkeeper
etag: 10de3a4430t7b8b1a19f9mdr558qa1d3
content-type: text/html; charset=utf-8

If you want to show verbose information to "make the operation more talkative", which can be useful when learning, use the -verbose or -v option. Doing this will also show information about the TLS handshake.

curl --verbose --HEAD --silent https://beamtic.com/

Note. The "-s" or "--silent" option activates "silent mode", which will hide progress bars.

To make the examples more user friendly, I have used the full option names (--OPTION_NAME) rather than the short versions (-O).

Comments