Part 3 [35 points total]: Write a basic URL testing client that can parse a given set of
URLs, connect to the web servers, send a HEAD request and parse the output and display it.
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 HEAD request, and
retrieve the response. You may not rely on any intrinsic language objects that
do HTTP retrieval for you.
- C [15 points]: Take the routines or objects constructed in the parts above
and construct an application that takes a filename that holds a set of URLs (one per
line) and tests each URL in turn. For each URL, the application must print: (1) the URL,
(2) whether the web site was reachable (if not, then why), (3) response code from the request (if any), and (4)
information from the HTTP headers that specify the object (if any). The HTTP headers to
be parsed are "Content-Type" and "Content-Length". You may not rely on any intrinsic language objects that
do HTTP parsing for you.
Part 4 [35 points total]: Write a prototype HTTP streaming data server for
various data streams. 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,
send back an HTTP response, and then stream data periodically back to the client.
Requests that are not "GET" should generate
a 501 status code and error return. Malformed requests should generate a 400 status code and response.
Requests for URLs that do not equate to streams should generate a 404 status code and
response.
- D [15 points]: Take the application above and add the following prototype
streams to it. Streams periodically send data back to the client until it disconnects.
The streams are: (1) clock - every 1 second, send a line containing the time in "Date" format. The URI
for this stream is "/clock", (2) random - every 1 second, send a line containing a random value from 1 to 1000. The
URI for this stream is "/random", and (3) uptime - every 1 second, send a line containing the output from
the "uptime" command. The URI for this stream is "/uptime".
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.26.2006)