Part 3 [60 points total]: Write a web proxy server.
This part requires multiple pieces to be done so I suggest
working on each part separately and verifying that each part works by itself. These parts are:
- A [5 points]: Construct a routine or object to parse an HTTP 1.0 request to break
it down into request method and URL. You may not rely on any intrinsic language
objects that do HTTP parsing for you.
- B [10 points]: Construct a routine or object to parse a given URL string in the form
http://hostname[:portnum]/pathname, where the part in
[] is optional, into (1) host IP address, (2) port, and (3) URI.
You may not rely on any intrinsic language objects that do URL parsing for you.
- C [15 points]: Construct a routine that uses the routine or object in part
B to take a URL, connect to the correct web server, send a HTTP/1.0 GET request, and
retrieve the response. You may not rely on any intrinsic language objects that
do HTTP retrieval for you.
- D [15 points]: Take the routines or objects constructed in the parts above
and construct an application that listens on a TCP port given on the command line,
accepts client connections, receives client HTTP requests,
parses HTTP requests, connects to and retrieves the object for the client, and returns
the object to the client as a HTTP proxy would.
Errors must be handled for hostnames that can not be looked up, for failed connection
to web servers, and for request methods other than GET (i.e. returning 501 Not Implemented).
- E [10 points]: Expand upon part D by caching the response from the web server
in a file. When another web client sends a request for the same object, return the
cached copy instead of going back to the original server.
- F [5 points]: Expand upon part E by checking if the web server has an
updated copy by sending an "If-Modified-Since" header with the date of the cached
copy and handling the HTTP response from the web server appropriately.
Notes:
Your submissions must at least compile before any credit will be given.
Submissions that do not compile will not be graded. Submissions submitted
after the due date will not be graded. All work must be your own original work.
To get partial credit for parts of the assignment, you must demonstrate that
those pieces work by themselves.
If you share code with others, you will be given a 0 for the assignment. This
assignment set is worth 25% of your total grade.
- HTTP 1.0 Specification at
http://www.w3.org/pub/WWW/Protocols/HTTP/1.0/spec.html
Todd L. Montgomery (revised 09.13.2005)