Part 3 [30 points total]: Write a basic web retrieval client that can parse a given
URL, connect to a web server, and retrieve the object and save it to a file.
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 [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.
- B [10 points]: Construct a routine that uses the routine or object above 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.
- C [10 points]: Take the routines or objects constructed in the parts above
and construct an application that takes a given URL string and retrieves the
object and saves it to a file (including headers and status line).
Errors must be printed for HTTP status codes other than 200 and for malformed
URLs.
Part 4 [30 points total]: Write a basic web server that can
handle the GET request method. You may not rely on any intrinsic language objects that do
any of this for you. This part requires multiple pieces to be done so I
suggest working on each part separately and verify that each part works by
itself. These parts are:
- A [5 points]: Construct a routine or object
that can read an HTTP/1.0
request from a socket and parse it into request method, request-URI, HTTP version,
headers, etc.
- B [5 points]: Construct a routine or object to construct a HTTP/1.0 response
given a status code, phrase, headers, and a body and send that response back on
a socket.
- C [10 points]: Take the routines or objects constructed above and
construct an application that listens on a port for connections. Connections
that are accepted should then be treated like HTTP requests and use the routines
or objects above. I.e. retrieve an HTTP request on a socket, parse it,
open the file indicated by the URI and send the contents back as an HTTP response. Files that can not be
opened should generate a 404 status code. Requests that are not "GET" should generate
a 501 status code. Malformed requests should generate a 400 status code and response.
- D [3 points]: Modify the above so that it sends back the "Date" header with
the time of day in it.
- E [3 points]: Modify the above so that it sends back the "Content-Length" header
with the correct object size.
- F [4 points]: Modify the above so that it sends back the "Last-Modified" header
with the correct object modification date.
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 01.31.2005)