CSCI 420 - Operating Systems & Concurrency

Spring 2017

Rust Web Server, part 1


In this assignment, we will develop a simple web server using Rust that responds to HTTP/1.1 GET requests. Follow these steps:
  1. Write a Rust program that listens for TCP requests on port 8888. (Your program should not panic.) When a request is received, the program should print the following:
  2. Next, refine your program as follows:
  3. The next step is to validate the request. A web server can be a security risk if it permits downloading of arbitrary files from the server. The requested file will be assumed to be based on the current working directory for the executing server. Make sure that the .. element is not present in a path, as that could easily enable an attacker to navigate the server's file system. If a request is valid, add the message Request Valid to the reply from the previous step. If not, send a message with the header HTTP/1.1 403 Forbidden in place of 200 OK.
  4. The server will maintain two counters: one counts the total number of requests, and the other counts the total number of valid requests. Each thread should properly update these counters. The counts should also be incorporated into the reply message above, and printed on the command-line.
  5. The last step is to respond to the request. Instead of sending the message above, send back the requested file. If the file is not present, reply with 404 Not Found.
Submit the last two programs via Moodle.


Completing each step above is worth 8 points. Therefore, the total value of the assignment is 40 points. No credit will be given for code that fails to compile. Partial credit may be given for incomplete or flawed versions of a given step.


This assignment was adapted from materials developed by David Evans at the University of Virginia.