Simple Web Server

Due: 5:00am, Friday, October 11, 2024

Get the Assignment Code

Login to your university Unix account and copy the assignment code to a location under your home directory:

The starter code for this assignment is on the Linux server here:

  /export/home/public/schwesin/cpsc328/assignments/project4

Description

The purpose of this assignment is to create a web server that can respond to simple HTTP GET requests. For example, given a request of:

GET /file.txt HTTP/1.1\r\n
Host: localhost\r\n
Connection: close\r\n
\r\n

Your server must parse the request to get the file path for the request and then construct an appropriate HTTP response. The directory that the server should serve files from is determined by the -d command line argument. Note that your server must ensure that files are only served from the given directory and its subdirectories. It is a security risk if a client can obtain files from arbitrary ancestor directories. If a client requests such a file, then the response code should be “404 Not Found”.

The form of the response will be similar to this:

HTTP/1.1 200 OK\r\n
Content-Type: text/plain\r\n
Content-Length: 5\r\n
Connection: close\r\n
\r\n
Hello

Here is the criteria for the response:

Here is the general flow of the program:

Specifications

Turning in the Assignment

To turn in the assignment, execute the submit script by running the command

  make submit

from within the project4 directory.

Grading Criteria

Note: If the submission includes material that was not covered in class and the material is not properly cited, then you will receive a failing grade for this assignment.