Web Server Assignment

Your task is to write a web server assignment.  Here's the point list
 
 
10,000 Can make a socket
10,000 Can receive a request of any form (either it acts on the request, or it just prints it to the screen)
10,000 Can read a file
10,000 Can write the file to a socket
10,000 Can parse a http/0.9 style request, and send the file to the client
10,000 Can parse a http/1.0 style request, and send the file to the client
10,000 Keeps the socket open if it's a http/1.1 style request
10,000 Works when I use netscape or IE
10,000 Works when I use netscape AND IE
10,000 Creates any reasonable log file
10,000 The log file is in "common logfile format".  See the file /var/log/http/access_log for examples.  You make fake the time field
5,000 The time in the logfile is actually correct
5,000 Works with sound and pictures
10,000 Any request of the form ~scott/fred.html gets translated to /home/scott/fred.html.  In other words, all ~blah becomes "/home/blah".
15,000 You send an "error page" if they offer you a bad request or nonexistant file
1,000 Dies with usage message if the program needs an argument and non are provided.
5,000 Can strip off CGI variables and still acess the files
20,000 CGI work
5,000 Sends the correct last modified time in the metadata
5,000 Has an error log
2,000 Translates a directory to index.html

This program is out of 150,000 points

How to open a file


int fd;
fd = open("/etc/passwd", O_RDONLY, 0);
if (fd == -1) {
    // They sent you a bad filename
    // don't perror and exit, send them the error page
}
 

How I Would Do This Program

Step 1)  Write a program that opens a socket, say 1234.  It should open the socket, read a line, and print it.
Then I would in IE or Netscape access the URL
http://euclid.nmu.edu:1234/home/myname/fred.txt
Stop, test, and bask in the warm glow of success.

Step 2)  I would add code to my program so that it seperated the first line it reads into words, and print the second word.  That should be the filename.  Stop, test, and bask in the warm glow of success.

Step 3) I would add code to the program so that it sends the file named by word2 down the socket. Stop, test, and bask in the warm glow of success.

Step 4) I would start adding extra features until I got all the points I wanted.  Stop, test, and bask in the warm glow of success.