Make Full GET Request But Only Display Headers - cURL

TL;DR - Here’s the command

curl -IXGET

which produces:

$ curl -IXGET
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:

  • -I - tells cURL to make a HEAD request. Delving through the source code shows adding this argument does nothing more than set the following CURLOPTs:
    • CURLOPT_NOBODY sets the request method to HEAD and ignores the response body if any was sent.
    • CURLOPT_HEADER makes cURL print the response headers in the body output.
  • -X - allows you to dumbly overwrite the HTTP request method sent with the request, in our case replacing HEAD that -I triggered with GET.

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

$ curl -XDONKEY -v -s -o /dev/null
> User-Agent: curl/7.37.1
> Host:
> 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 -

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