I recently had a conversation with a certain programmer friend who, having foolishly overwritten his Firefox 3.0x with an installation of the 3.1 beta, was unable to use any of his plugins. This wasn't a huge problem for him--i.e. he figured he could live without his plugins for a week or two--until he realized that he wasn't going to be able to use LiveHTTPHeaders (http://livehttpheaders.mozdev.org/).
The plugin, which can greatly expedite client-side testing, is not the only way to do that sort of testing. In a pinch, you can view HTTP headers on the command line simply by firing up a terminal session and using wget:
$ wget -S almosteffortless.com -O /dev/null
The majuscule "S" gets you the headers and the "-O /dev/null" dumps the file you're about to retrieve in the bit bucket (rather than into your home directory or where ever). The output you get looks something like this:
toconnell@lana:~/tmp$ wget -S almosteffortless.com --2008-10-21 13:43:24-- http://tyrannybelle.com/ Resolving tyrannybelle.com... 208.78.99.165 Connecting to tyrannybelle.com|208.78.99.165|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 200 OK Date: Tue, 21 Oct 2008 18:43:25 GMT Server: Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch mod_python/3.3.1 Python/2.5.2 mod_ssl/2.2.9 OpenSSL/0.9.8g X-Powered-By: PHP/5.2.6-5 Set-Cookie: PHPSESSID=aefe500683f79ed067f91f76d3615d33; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 4932 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html Length: 4932 (4.8K) [text/html]
You can see cookie info, cache and pragma values, Apache information and so on. Not too shabby.
I showed this to my pal and, though he was a little impressed, he wasn't entirely convinced that he was going to be able to do all of his client testing using only the CLI: "yes, that's all fine and good", he said, "but I usually need to right-click and 'View Page Source' in order to check on dynamically generated content."
"You're not going to want to hear this," I responded, "but telnet is your friend on this one."
toconnell@lana:~/tmp$ telnet tyrannybelle.com 80
Will connect you to your website. All you've got to do at that point is manually GET your document. Let's say, for the example, that we just want our index. All you do, once you're connected, is
GET /
telnet will then proceed to make the request, dump the response onto your terminal as html and exit.
Granted, you don't get any syntax highlighting or fancy stuff, but if you're debugging from a mobile device, a computer without windowing software or in any other circumstance you can't use a proper browser, telnet is a great way to eyeball a website.
My friend admitted that this was, in fact, all right in a pinch, but it was plain from the look on his face that he still wasn't sold on ye olde command line as a testing/debugging tool. "What about layout?" he asked.
"Well yeah," I conceded, "there's really no good way to do that without a browser, but if you want to check on your tab order..."
And then, just as I was about to start in lynx, he said, "you know what? Forget it--I'm just going to go ahead and trash this beta install."





wget -S is cool as I did not know about that option in wget. It does however annoyingly stick a index.html in your current path.
I have this in my .zshrc.
function http_headers {
curl=’whence curl’
curl -I -L $@
}
Which will do basically the same thing with curl minus cluttering up my path. Keep in mind whence won’t work in bash, you’ll need to replace it with which or whatever bash offers for a speeder internal command.