Exercise 2. Understand HTTP 1.1 usig fake web server and web client.
In this exercise, you will first
run a fake web serve using ~cs522/bin/ws to find out the http request sent
by a browser. Then we will use telnet <domainname> <portno> as
a fake browser to find out what is the http resposne of a web server.
If we type in ~cs522/bin/ws 9338 on blanca.uccs.edu, then type in http://blanca.uccs.edu:9338/~cs401/ on a IE browser. We will see the following message on the console. The message received is the http request sent by the browser with http request command link "GET /~cs401/ HTTP/1.1" followed by 6 headers lines.
All header lines has header name
followed by ":" then by the value of the header.
The Accept header indicates the type of file format accepted by the browser.
The Accept-Language header is en-us. It can be by the server to return the
US English version of the web page.
The Accept-Encoding indicates the acceptable compression method.
The Use-Agent meta header indicates the versionof the browser that submitted
the request. It may include the related OS version, SSL package number. Here
it shows the browser is MS IE version 6.0 running on a machine with NT5.1
OS (XP).
To comply with HTTP/1.1 protocol, the browser needs to supply the Host header
with the domain name and port number in the url entered by the user. Here
it is blanca.uccs.edu:9338.
Connection header has value Keep-Alive, which means the browser requests the
TCP connection to be kept alive for future http request. This feature reduces
the 3-way handshake overhead for those future requests.
blanca.uccs.edu>
~cs522/bin/ws 9338
ws 9338
argv[1]=9338
portno=9338
before getsockname socket has port #9338
socket has port #9338
rcvd msg-->GET /~cs401/ HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash,
*/*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;
.NET CLR 1.0.2914; .NET CLR 1.1.4322)
Host: blanca.uccs.edu:9338
Connection: Keep-Alive
What is your reply ("#" to end multilineinput; "$" to
break connection)?
HTTP/1.1 200 OK
Date: Mon, 18 Aug 2003 22:25:16 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Last-Modified: Sun, 17 Aug 2003 18:06:53 GMT
ETag: "b4dc6a-3866-c01bc940"
Accept-Ranges: bytes
Content-Length: 18
<html>OHHHH</html>
The above interaction shows that when the fake web ask "what is your reply?" We type in the http response (pretend we are the web server). The First line is the http response line. The 200 is the response code, which indicate the web page is retrieve successfully. The remaining six headers indicate
Date: the date the response is
created,
Server: the version of the server that returns the response
Last-Modified: indicates the web page last modified date
ETag: A hash value can be submitted in the future for verifying the version
of document has been updated.
Accept-Range: bytes (HTTP1.1 only support bytes. A http request can use Range
header to request portion of a document.)
Content-Length: indicates the the length of the attached document after the
http response header. Here it is 18 bytes.
Note the the header and body are separated by two CRLF after the last http
header.
Here is another run with different
browser from the same machine.
sanluis.uccs.edu> ws 8338
argv[1]=8338
portno=8338
before getsockname socket has port #8338
socket has port #8338
rcvd msg-->GET /sales/sales.html HTTP/1.1
Host: sanluis.uccs.edu:8338
User-Agent: Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
The following are the response of a web server capatured using "telnet
cs.uccs.edu 80 > out.txt " and enter
GET / HTTP/1.0
<enter>
<enter>
Trying 128.198.162.68...^M
Connected to cs.uccs.edu.^M
Escape character is '^]'.^M
HTTP/1.1 200 OK
Date: Mon, 18 Aug 2003 22:25:16 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Last-Modified: Sun, 17 Aug 2003 18:06:53 GMT
ETag: "b4dc6a-3866-c01bc940"
Accept-Ranges: bytes
Content-Length: 14438
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<!doctype html public "-//w3c//dtd
html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="C. Edward Chow">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT;
I) [Netscape]">
<title>CS522 F2003 Home Page</title>
</head>
<body background="marble1.jpg">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<HTML>
<!-- University of Colorado at Colorado Springs, UCCS, Colorado University,
College -->
<HEAD>
<TITLE>University Of Colorado At Colorado Springs</TITLE>
<html><head><title>Site
Not Found</title></head>
<body>No web site is configured at this address.</body></html>
It indicates csweb.uccs.edu runs the Microsoft-Internet
Information Server version 5.0.
HTTP/1.1 200
OK
Date: Mon, 22 Sep 2003 15:46:20 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Last-Modified: Thu, 21 Aug 2003 14:51:10 GMT
ETag: "28c4b-127-7b895380"
Accept-Ranges: bytes
Content-Length: 295
Connection: close
Content-Type: text/html; charset=ISO-8859-1
We only see the http headers and no content.
HTTP/1.1 200
OK
Date: Mon, 22 Sep 2003 15:49:53 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Last-Modified: Thu, 21 Aug 2003 14:51:10 GMT
ETag: "28c4b-127-7b895380"
Accept-Ranges: bytes
Content-Length: 295
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<title>College of Engineering and Applied Science</title>
<meta http-equiv="refresh" content="3;url=http://eas.uccs.edu">
</head>
<body>
<H1>
<br><br><br><br>
<p align="center">THE ADDRESS FOR THE NEW WEBSITE IS:</p>
<br>
<p align="center">eas.uccs.edu</p>
</H1>
</body>
</html>
HTTP/1.1 304
Not Modified
Date: Mon, 22 Sep 2003 15:53:05 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Connection: close
ETag: "28c4b-127-7b895380"
Exercise 3 Web Page with Form.
blanca.uccs.edu>
cd ~cs522/bin
blanca.uccs.edu> ws
8345
argv[1]=8345
portno=8345
before getsockname socket has port #8345
socket has port #8345
rcvd msg 348 bytes-->
POST /cgi-bin/cs522/processOrder.pl HTTP/1.0
Referer: http://blanca.uccs.edu/~cs522/hw/hw1/orderForm.html
Connection: Keep-Alive
User-Agent: Mozilla/4.7 [en] (WinNT; I)
Host: blanca.uccs.edu:8345
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png,
*/*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
What is your reply ("$" to break connection)?
rcvd msg 351 bytes-->
Content-type: application/x-www-form-urlencoded
Content-length: 277
butter=1&chocolate=1&mint=3&mm=5&peanut=0&name=C.+Edward+Chow&email=chow%40cs.uc
cs.edu&telephone=%28719%29262-3110&creditCardType=Visa&creditCardNo=3333+2222+44
44+5555&expireDate=02%2F02&shippingAddress=ENS+186%0D%0AUCCS%0D%0AColorado+Springs%2C+CO+80918%0D%0AUSA&.submit=order
What is your reply ("$" to break connection)?
sanluis.uccs.edu>
ws 8352
argv[1]=8352
portno=8352
before getsockname socket has port #8352
socket has port #8352
rcvd msg-->POST /cgi-bin/cs301/processOrder.pl HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash,
*/*
Referer: http://sanluis.uccs.edu/~cs526/orderForm.html
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705; .NET CLR 1.0.2914; .NET CLR 1.1.4322)
Host: sanluis.uccs.edu:8352
Content-Length: 305
Connection: Keep-Alive
Cache-Control: no-cache
butter=1&chocolate=1&mint=3&mm=5&peanut=0&name=C.+Edward+Chow&email=chow@cs.ucs.edu&telephone=%28719%29262-3110&creditCardType=Visa&creditCardNo=1111+2222+3333+4444&expireDate=02%2F00&shippingAddress=C.+Edward+Chow%0D%0A1420+Austin+Bluffs+Parkway%0D%0AColorado+Springs%2C+CO+80933-7150%0D%0A&.submit=order
What is your reply ("#" to end multilineinput; "$"
to break connection)?
HTTP Header Name | Section # in HTTP 1.1 Specification | MSIE 6.0 | Netscape 4.7 |
Accept | http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 | It has longer list of MIME types | |
Accept-Charset | http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2 | no such field | iso-8859-1,*,utf8 |
Cache Control | http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 | no-cache | no such field |