Question:
Your task is to write a simple HTTP Server. There is only a limited range of content that needs to be served, and it only needs to respond to GET requests. The content that needs to be served is as follows:
Content File Extension
HTML .html
JPEG .jpg
CSS .css
JavaScript .js
You can assume that all files have a valid file extension
Answer:
Introduction
The objective of this project is to increase familiarity with socket programming, multi-threading, and the HTTP protocol. A basic HTTP server that responds correctly to a limited set of GET requests has been implemented in C programming language. The HTTP server is designed to return valid response headers for a range of files and paths. The HTTP handling code has been written from scratch and does no in any way make use of existing HTTP libraries.
Project Details
The HTTP Server is made to be simple with the ability to respond only to GET requests and serves only a limited scope of content.
Assumptions Made
- All file have valid file extensions
- No Support for pipelining or persistent connection is required.
- Request headers are valid
Functionality Achievements
- Implementation of a HTTP 1.0 Server.
- Multiple incoming requests processing support using Pthreads.
- Server support for 200 response on successful access.
- Server support for 404 response when the requested file lacks
- show Http Status and Content-typewq in the header response.
Program Inputs
In order to achieve desired output. The program expects the following command line arguments:
- Port Number
- string path to the root web directory.
The port number specified is the one on which the server will listen for connections.
The string path to the root web directory is the path to resources to be served.