Why does this not work:
curl -X HEAD http://www.google.com
But these both work just fine:
curl -I http://www.google.com curl -X GET http://www.google.com
To make a GET request using Curl, run the curl command followed by the target URL. Curl automatically selects the HTTP GET request method unless you use the -X, --request, or -d command-line option.
To pass multiple headers in a curl request you simply add additional -H or --header to your curl command. For standard HTTP header fields such as User-Agent, Cookie, Host, there is actually another way to setting them.
Curl by default adds headers such as Content-type and User-agent .
The -I option is used to tell curl to only fetch the HTTP headers ( HEAD method) of a particular page or resource.
You need to add the -i flag to the first command, to include the HTTP header in the output. This is required to print headers.
curl -X HEAD -i http://www.google.com
More here: https://serverfault.com/questions/140149/difference-between-curl-i-and-curl-x-head
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With