=================================================== sample HTTP session using the "netcat" (nc) command =================================================== -Ian! D. Allen - idallen@idallen.ca - www.idallen.com The "nc" (netcat) TCP/IP "Swiss Army Knife" program is a "pure" way to connect your keyboard with a remote TCP/IP daemon. It is similar to "telnet", except it doesn't try to auto-negotiate any line parameters first. It is useful for connecting directly to many text-based Internet protocols. Use "nc" in preference to "telnet", when available. One such text-based protocol is the Hyper Text Transfer Protocol (HTTP) used to send and receive Web pages over the Internet. It is documented in RFC2616: http://tools.ietf.org/html/rfc2616 http://www.faqs.org/rfcs/rfc2616.html My input is marked by "*" in the examples below. Note the blank line used to signal the end of my input to the server. In 2006: * $ nc -v www.microsoft.com http lb1.www.ms.akadns.net [207.46.18.30] 80 (http) open * HEAD / HTTP/1.0 * HTTP/1.1 200 OK Connection: close Date: Thu, 02 Feb 2006 08:29:31 GMT Server: Microsoft-IIS/6.0 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 X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 22874 In 2011: * $ nc -v www.microsoft.com http Connection to www.microsoft.com 80 port [tcp/www] succeeded! * HEAD / HTTP/1.0 * HTTP/1.1 200 OK Cache-Control: no-cache Content-Length: 1020 Content-Type: text/html Last-Modified: Mon, 16 Mar 2009 20:35:26 GMT Accept-Ranges: bytes ETag: "67991fbd76a6c91:0" Server: Microsoft-IIS/7.5 VTag: 791558442600000000 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: Fri, 04 Nov 2011 08:45:00 GMT Connection: keep-alive You can also use "GET" instead of "HEAD" to fetch an entire raw web page. The server below requires the "Host" subcommand (typed after the "GET" command) to choose the correct virtual web server on the shared machine that has multiple domains, so we use the HTTP/1.1 protocol (not 1.0): In 2006: * $ nc -v teaching.idallen.com http DNS fwd/rev mismatch: idallen.com != server20.tchmachines.com idallen.com [216.180.243.122] 80 (http) open * GET /net2003/06w/notes/README.txt HTTP/1.1 * Host: teaching.idallen.com * HTTP/1.1 200 OK Date: Thu, 02 Feb 2006 08:33:32 GMT Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.6b Last-Modified: Sat, 10 Dec 2005 03:57:42 GMT ETag: "39298c-1a7-439a5236" Accept-Ranges: bytes Content-Length: 423 Connection: close Content-Type: text/plain ======================================== README - Index to this NET2003 directory ======================================== Ian! D. Allen - idallen@idallen.ca This directory contains a set of notes for BIT NET2003. File names of the form "week01notes.txt" are study notes and exercises for each week. Read these files to know what to do each week. File names of the form "exercise01.txt" are exercises to be completed. In 2011: * $ nc -v teaching.idallen.com http Connection to teaching.idallen.com 80 port [tcp/www] succeeded! * GET /net2003/06w/notes/README.txt HTTP/1.1 * Host: teaching.idallen.com * HTTP/1.1 200 OK Date: Fri, 04 Nov 2011 08:56:31 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Last-Modified: Tue, 04 Jan 2005 18:22:41 GMT ETag: "1cf072a-1a7-3ecddf450de40" Accept-Ranges: bytes Content-Length: 423 Content-Type: text/plain ======================================== README - Index to this NET2003 directory ======================================== Ian! D. Allen - idallen@idallen.ca This directory contains a set of notes for BIT NET2003. File names of the form "week01notes.txt" are study notes and exercises for each week. Read these files to know what to do each week. File names of the form "exercise01.txt" are exercises to be completed. -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/