Do you curl a lot to check headers?

05 September 2014   5 comments   Linux

Mind That Age!

This blog post is 4 years old! Most likely, its content is outdated. Especially if it's technical.

I, multiple times per day, find myself wanting to find out what headers I get back on a URL but I don't care about the response payload. The command to use then is:

curl -v > /dev/null

That'll print out all the headers sent and received. Nice and crips.

So because I type this every day I made it into a shortcut script

cd ~/bin
echo '#!/bin/bash
> set -x
> curl -v "$@" > /dev/null
> ' > c
chmod +x c

If it's not clear what the code looks like, it's this:

set -x
curl -v "$@" > /dev/null

Now I can just type:


Or if I want to add some extra request headers for example:

c -H 'User-Agent: foobar'


Chris Adams
I did that a lot but now I just `pip install --user httpie`. It has the nice default of not dumping binary data to the console and pretty-printing text responses (no more compressed HTML or JSON blobs) and "http --print h …" will always print only the headers.
James Edward Gray II
curl -I …
Peter Bengtsson
The server might respond differently if given a HEAD request.
Jarod McBride
Peter, thanks for the post. What's the difference you get from the above as opposed to running curl -v -I ?
Peter Bengtsson
First of all, the difference is that "curl -v" is 7 characters. Just "c" is 1 character :)
This matters if you type it a lot.

Also, the -I means it does a HEAD request and the server might respond differently. For example the Content-Length header might be wrong/different.

Your email will never ever be published

Related posts

An AngularJS directive with itself as the attribute 03 September 2014
Premailer on Python 3 08 October 2014
Related by Keyword:
How to test if gzip is working on your site or app 20 August 2015
Interesting lesson learnt on shortcut taking in usability 02 August 2007
Related by Text:
Be very careful with your add_header in Nginx! You might make your site insecure 11 February 2018
jQuery and Highslide JS 08 January 2008
I'm back! has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
I'm Prolog 01 May 2007