Archive for January, 2012

How to speak HTTP (test web page via telnet)?


Let’s say you’re debugging a problem and you need to test the home page of a site http://WWW.DOMAIN.NAME/

* From a Terminal or Command prompt, do this:

telnet WWW.DOMAIN.NAME 80

* then type:

GET / HTTP/1.0

* then press the Enter(return) key twice!

* it will then spit back the html for that particular url — in this case the “/” just means the home page.

* if you only want to see the HTTP headers and not the whole html of that page, then:

HEAD / HTTP/1.0

* another example?  let’s say you want to test a different page whose URL is http://WWW.DOMAIN.NAME/contact.html.  Then:

GET /contact.html

here’s an example session:

++++++++++++++++++++

~/ $ telnet downtownweb.com 80
Trying 96.44.179.35...
Connected to downtownweb.com (96.44.179.35).
Escape character is '^]'.
HEAD /contact.html HTTP/1.0

HTTP/1.1 200 OK
Server: nginx/1.0.11
Date: Sun, 22 Jan 2012 06:16:28 GMT
Content-Type: text/html
Connection: close
Cache-Control: max-age=3600
Expires: Sun, 22 Jan 2012 07:16:28 GMT
Vary: Accept-Encoding,User-Agent

++++++++++++++++++++

 

P.S. that’s it for now.  i’ll try to show advanced stuff later.

P.P.S. If you’re familiar with the cURL utility — using the HEAD method is the same as running:

curl -I http://WWW.DOMAIN.NAME

No Comments