To perform an HTTP HEAD request with
curl, you can use the
--head option. Here’s an example:
curl -I http://example.com
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
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" http://example.com
This will send a
POST request with the
data parameter set to "test", and print the response to the console.