SE 550: Homework 2

Deadline: 5.30pm, Tuesday January 20, 2004

Homework

This week's homework is to extend the previous week's homework to allow compressed files to be displayed in the HTTP client.

If the user enters a URL which ends with ".gz", then the uncompressed version of the file should be displayed. For example, if the user enters:

  http://fpl.cs.depaul.edu/ajeffrey/se550/index.html.gz

then the client should download the compressed file (index.html.gz) and uncompress it, to display:

<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Alan Jeffrey">
   <TITLE>SE550: Distributed Software Development</TITLE>
</HEAD>
<frameset cols=150,*>
  <frame src=toc.html name=toc>
  <frame src=title.html name=body>
</frameset>
</HTML>

You should edit the file HTTPIO.java to support this functionality.

Note: you should not use any deprecated methods to solve this.

Hint: Use the built-in URL and GZIPInputStream classes.

Another hint: This problem is harder than it looks! It is very easy to get an exception:

  java.io.IOException: Not in GZIP format

This means that you are not providing a `proper' gzip-compressed input stream to the GZIPInputStream. You should look at the contents of the stream to make sure it is the same as the file on the server. Remember that many of the java.io classes include some buffering, which can cause serious problems with implementing mixed binary- and text-based protocols.

Yet another hint: The HTTP protocol requires all header information to be in 8-bit ASCII (no Unicode!) and requires all lines to end with `\r\n'. This is very useful!

Submit any source code files you edited as a zip archive using Courses OnLine.

Reading

Harold Chapter 2, section on Internet Standards.

Johnsonbaugh Discrete Mathematics, Section 10.3 Languages and Grammars.