Posted: September 13th, 2017

CSP2308 Assignment 1;

CSP2308 Assignment 1;

Background:
This is the start of creating a basic web server. In Assignment 1 we will focus on using a GET command and fulfilling (printing) it. Assignment 2 will add network communications (sockets), more robust programming, threads and parsing of the URI from a normal web browser so you can extract (and fulfil) a GET request.
This version of the web server will run locally, receive requests from the keyboard (console) and fulfil them with local resources only. There is no networking in this version.
Objectives:
Design and Write a program that does the following:
•    Loads and uses mywebserver.conf to set internal variables as mentioned below.
o    If mywebserver.conf doesn’t exist, your program should terminate gracefully with an appropriate message and code.
o    If mywebserver.conf isn’t readable, your program should terminate gracefully with an appropriate message and code. This is different from the file not existing.
•    Takes a HTTP GET command from the keyboard. GET is a HTTP keyword used to request a resource. The resources we will be dealing with are exclusively files.
•    Checks if the requested file exists on the local filesystem that your program runs on, if not responds with an appropriate error message
•    Checks if the file is readable by your program, if not responds with an appropriate error message
•    If the file exists on the local filesystem and is readable:
o    open the file
o    read the contents
o    print the contents to STDOUT
•    If the QUIT_NOW request is given, your program should terminate gracefully with an appropriate message and code
•    If the RELOAD_CONFIG request is given then
o    open your programs configuration file
o    read in the configuration file
o    reset your programs parameters based on the configuration you read in

Your program should use a configuration file that should provide at a minimum:
•    The default file to load for GET /

Using  make to manage (at minimum) these files:
mywebserver.c
This should contain the main logic of your code

myfiles.c
This file should contain any functions that handle file operations

mywebserver.conf
This file should be a configuration file that you can use to set the behaviour of your main program. The required configuration options are small at the moment but this will be more heavily used in the second assignment.

Other possible files you could use to break up the structure of your program:
myinput.c
This file could handle all input including safely checking if the input is valid, checks against exploits such as buffer overflows or directory traversal. HTTP parsing could be included here or in its own file.

myparser.c
This file could handle parsing HTTP requests beyond GET if you wanted to challenge yourself. Basic parsing of a URI is something that you will have to do in Assignment 2.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Live Chat+1-631-333-0101EmailWhatsApp