Make Full GET Request But Only Display Headers - cURL

TL;DR - Here’s the command

curl -IXGET http://example.com/file.txt

which produces:

$ curl -IXGET http://www.woolie.co.uk
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 1662
Cache-Control: max-age=3600
Content-Encoding: gzip
ETag: "491e3f837bca4470f09871ab186a93a7"

For the curious - What does IXGET do?

The -IXGET argument stumped me for a while, mainly because my brain was parsing -IXGET as one argument. It’s actually layering 2 arguments:

If you feel like confusing a server, cURL doesn’t sanity check -X and you can overwrite it with whatever you fancy:

$ curl http://www.google.co.uk/ -XDONKEY -v -s -o /dev/null
> DONKEY / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: www.google.co.uk
> Accept: */*
>
< HTTP/1.1 405 Method Not Allowed
< Content-Type: text/html; charset=UTF-8
< Content-Length: 1455
< Server: GFE/2.0

Other Methods of Achieving the Same

For years I’d always used the following cURL arguments to achieve the same as -IXGET:

curl -s -o /dev/null -D - http://example.com/file.txt

This asks to send all HTTP response body to /dev/null but to dump the response headers to stdout.