Laboratory Week 4 - HTTP Requests and Responses
Learning Objectives:
- Understand the format of messages passed between a web server and a web client.
Before doing the tutorial, please read:
- Topic 3 lectures on "Internals of Web Servers" and "Internals of Web Clients".
Software required:
- This lab requires the use of a SSH and an FTP program. The software is available in the internal labs. External students may download the required software from the unit's downloads page.
- We have set up accounts on a Unix server phoenix.murdoch.edu.au for you to use. Instructions on logging on to the machine is given in week 3's lab. Students who enrolled after the start of semester may not have an account yet. If you find you cannot log on using the instructions below, you will need to contact the unit coordinator to request an account. Clearly state your name and student number when you make your request.
Exercises:
In this laboratory, you will be using special web client and web server programs to see what kind of HTTP requests and responses are sent and received in normal web communications. These messages are usually hidden from users, but they are essential to the operation of the web browsers and web servers. Make sure you understand week 3's lectures on web servers and web clients before proceeding.
The programs are basically simple versions of your web browsers (eg. Microsoft Internet Explorer and Netscape Navigator) and web servers (eg. Apache and Microsoft IIS). These programs have been modified to show you what messages they receive and send, so you may appreciate the communication that happens between web clients and web servers.
HTTP Request Messages
We will use a simple web server to show what HTTP request messages your own web browsers send. This web server is running on phoenix on port 21100. Unlike normal web servers, all this server program does is send back to your browser what HTTP request messages it receives.
- Using any web browser, type in the following URL:
http://phoenix.murdoch.edu.au:21100/index.html
What will appear on your browser is the HTTP request message your browser sent. Note some of the key information: the all important Request Line (the first line), the Accept field (the media formats your browser says it is willing to accept), the User-Agent field (the name used by your browser) etc.
Now try the following URLs as well:
http://phoenix.murdoch.edu.au:21100
http://phoenix.murdoch.edu.au:21100/abc/def/nothing.gif
http://phoenix.it.murdoch.edu.au:21100
Note the differences between the HTTP requests sent for each of the different URLs.Now repeat the previous exercises using other browsers on your desktop (the internal labs have Microsoft Internet Explorer and Netscape Navigator). Look at the differences between the HTTP request messages sent by the different browsers. Note especially:
- How the request line remains the same for the different browsers.
- There are some standard header fields that all browsers send, but the values of the headers are not exactly the same. Eg. they all have the Accept field, but different browsers says they can accept different media types.
HTTP Response Messages
- We will now do the exercises in the reverse direction from the above. We will use a simple web client to show what HTTP response messages different web server send. This web client is available on phoenix at "~hiew/bin/web_client.pl". Unlike normal web browsers, all this client program does is display on the command line what HTTP response messages it receives.
Note here that we are now using phoenix as a client and not a server. A machine can have multiple programs running on it, some acting as clients and some acting as servers.
Using an SSH session, log in to phoenix.murdoch.edu.au and run the web client program. Below is a sample session of what you should see. The characters in bold is what you type in. The "|" character is the vertical bar character, not "1". The sequence "| more" basically means display the results one screen at a time. Note also that the whole command sequence between each "phoenix:~>" prompt should be typed in one line. Your browser may be showing you the example below in multiple lines due to your window size.
phoenix:~> ~hiew/bin/web_client.pl http://www.murdoch.edu.au | more
HTTP/1.1 200 OK
Connection: close
Date: Thu, 05 Aug 2002 04:21:16 GMT
Transfer-Encoding: chunked
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_ssl/2.8.9 OpenSSL/0.9.6d mod_perl/1.26 mod_fastcgi/2.2.10
Content-Type: text/html
Client-Date: Thu, 08 Aug 2002 04:21:19 GMT
...
What will appear on your screen is the HTTP response message the web server for www.murdoch.edu.au sent. Note some of the key information: the all important Status Line (the first line), the header fields, the HTML file content after the headers, etc.
Now try the same thing for other URLs:
phoenix:~> ~hiew/bin/web_client.pl http://www.murdoch.edu.au/aaa.html | more
phoenix:~> ~hiew/bin/web_client.pl http://www.linux.org.au | more
phoenix:~> ~hiew/bin/web_client.pl http://www.uwa.edu.au | more
phoenix:~> ~hiew/bin/web_client.pl http://www.microsoft.com.au | moreYou may even connect to the web server we used in the previous section. Note at the end of the response message is what you saw on your browser in the previous section.
Note the differences between the HTTP responses sent by the different web servers for each of the URLs.phoenix:~> ~hiew/bin/web_client.pl http://phoenix.murdoch.edu.au:21100 | more
Don't forget to keep up with current developments. Test your knowledge of major developments by going through the Good News Week self-tests. Your final exam will contain questions of the same type.
H.L. Hiew
Unit Coordinator
Document author: H.L. Hiew,
Unit Coordinator
Last Modified:
Saturday, 24-Aug-2002 19:44:00 MST
Disclaimer & Copyright
Notice © 2002 Murdoch University