There Are HTTP Headers, And Then There Are HTTP Headers

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, August 28, 2008

Follow me on Twitter as @mattiasgeniar

Sounds confusing? No worries, it’s really not. Here are some standard HTTP headers from a random website.

[root@vps ~]# curl --head https://ma.ttias.be
HTTP/1.1 200 OK
Date: Thu, 28 Aug 2008 17:58:15 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
X-Pingback: /xmlrpc.php
Set-Cookie: PHPSESSID=sudpae35dbuesipfiouipcbue0; path=/
Connection: close
Content-Type: text/html; charset=UTF-8

Nothing special about it, perhaps the X-Pingback is a bit odd – it’s added by wordpress to allowed automatic pingbacks to certain articles. You have your typical date, server, connection & content-type shown to you.

Some sites however … like to add some special things. Slashdot for instance adds a new Futurama quote with every page you load. It’s hidden to 99,9% of the users out there – only the geeks who actually look at the headers will see this.

[root@vps ~]# curl --head http://slashdot.org          
HTTP/1.1 200 OK
Date: Thu, 28 Aug 2008 18:02:27 GMT
Server: Apache/1.3.41 (Unix) mod_perl/1.31-rc4
SLASH_LOG_DATA: shtml
X-Powered-By: Slash 2.005001217
X-Bender: They're tormenting me with uptempo singing and dancing!
Cache-Control: private
Pragma: private
Connection: close
Content-Type: text/html; charset=iso-8859-1

Note the X-Bender: They’re tormenting me with uptempo singing and dancing! quote in there! You’ll also find quotes by Leela & Fry.

  • X-Bender: I only know enough binary to ask where the bathroom is.
  • X-Bender: Gimme your biggest, strongest, cheapest drink.
  • X-Leela: This is by a wide margin the least likely thing that has ever happened.
  • X-Leela: This toads the wet sprocket.
  • X-Fry: You mean Bender is the evil Bender? I’m shocked! Shocked! Well not that shocked.
  • X-Fry: I must be a robot. Why else would human women refuse to date me?

It’s probably been known for a while, but it was knew to me. Kinda cool – now I’m looking at ways to add fancy headers for this server as well … :-) You can read more about it on this Fun With HTTP Headers article!

Edit: turns out it is incredibly easy to add a custom http header to apache. Just enable the use of .htaccess and you can add all the headers you like. Add the following line, to create a “X-Who-Rocks”-header!

Header set X-Who-Rocks "Mattias Geniar"

This is what the headers for this site now look like! Muchos better! :-)

[root@vps httpdocs]# curl --head https://ma.ttias.be
HTTP/1.1 200 OK
Date: Thu, 28 Aug 2008 18:23:48 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
X-Pingback: /xmlrpc.php
Set-Cookie: PHPSESSID=ibmsf43qjjnkc6h6fudfok0sp5; path=/
X-Who-Rocks: Mattias Geniar
Connection: close
Content-Type: text/html; charset=UTF-8

Yarrr!



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.