There Are HTTP Headers, And Then There Are HTTP Headers

Mattias Geniar, Thursday, August 28, 2008

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: https://ma.ttias.be/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: https://ma.ttias.be/xmlrpc.php
Set-Cookie: PHPSESSID=ibmsf43qjjnkc6h6fudfok0sp5; path=/
X-Who-Rocks: Mattias Geniar
Connection: close
Content-Type: text/html; charset=UTF-8

Yarrr!



Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek, public speaker and podcaster. Currently working on DNS Spy. Follow me on Twitter as @mattiasgeniar.

I respect your privacy and you won't get spam. Ever.
Just a weekly newsletter about Linux and open source.

SysCast podcast

In the SysCast podcast I talk about Linux & open source projects, interview sysadmins or developers and discuss web-related technologies. A show by and for geeks!

cron.weekly newsletter

A weekly newsletter - delivered every Sunday - for Linux sysadmins and open source users. It helps keeps you informed about open source projects, Linux guides & tutorials and the latest news.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!