17 September 2007

Cheapo productions surfing

I was shuffling reference books about, generally moving the less frequently-used ones to the shelves in the basement, and I picked up Shishir Gundavaram's CGI Programming on the World Wide Web (O'Reilly, 1996). Definitely one to move to the archive shelves. And yet—there is a sticky note on page 373, and it's there to mark a passage that describes a low-tech way to check on a web server using telnet:

% telnet www.google.com 80
Trying 64.233.169.104...
Connected to www.l.google.com.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.0 200 OK
Cache-Control: private
Content-Type: text/html; charset=ISO-8859-1
Server: gws
Date: Tue, 18 Sep 2007 02:16:00 GMT
Connection: Close

<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>
...
</body></html>Connection closed by foreign host.
%

You can use this technique to see the unvarnished HTML payload without doing a View>Page Source, as well as the HTTP headers. Best way to find out who's running Apache, who's running IIS, who's running something custom.

It's easy to run telnet from a Mac OS Terminal window: just remember to hit the enter key twice after you type type the GET line. I was less successful running telnet from a Windows Command Prompt window.


% telnet www.microsoft.com 80
Trying 207.46.19.254...
Connected to toggle.www.ms.akadns.net.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: /en/us/default.aspx
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
X-Powered-By: ASP.NET
Date: Tue, 18 Sep 2007 02:26:39 GMT
Connection: keep-alive
Content-Length: 136

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/en/us/default.aspx">here</a>.</h2>
</body></html>
Connection closed by foreign host.
%


When I hit the server at Amazon.com, the last line of HTML consisted of the comment string <!-- MEOW -->. Go figure.