Linux · March 30, 2023 0

How to perform an HTTP HEAD request with curl?

Table of Content

To perform an HTTP HEAD request with curl, you can use the -I or --head option. Here’s an example:

curl -I

This will send a HEAD request to the specified URL and print the response headers to the console.

Note that the -I option is not necessary for curl to perform a HEAD request, as curl will automatically use the HEAD method if the request URL does not contain a request body. However, using the -I option makes it explicit that you are sending a HEAD request and can be useful for clarity.

Additionally, you can use other HTTP methods (such as GET, POST, PUT, etc.) with curl by specifying the -X option followed by the HTTP method. For example, to send a POST request with data to the specified URL, you can use the following command:

curl -X POST -d "data=test"

This will send a POST request with the data parameter set to "test", and print the response to the console.

%d bloggers like this: