abc abc - 3 months ago 27
Linux Question

curl usage to get header

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

Answer

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: http://serverfault.com/questions/140149/difference-between-curl-i-and-curl-x-head