A complete HTTP server built from scratch in C/C++.
Overview
This project implements a fully functional HTTP server that can serve static files,
execute CGI programs, browse directories, enforce Basic HTTP authentication,
track statistics, and support three different concurrency modes (see below).
All request parsing, header generation, directory traversal, and process/thread logic
were implemented manually.
Core Features Implemented
Full HTTP request parsing (method, path, headers, CRLF handling)
GET and HEAD support for serving static files from http-root-dir
Basic HTTP Authentication using Base64-encoded credentials
Directory browsing with automatic HTML generation
Sorting by name, size, modification time
Cgi-bin execution using fork + execv
POST method implementation
Stats page showing uptime, request count, min/max service time
Concurrency Modes
The server supports three different concurrency models selected via command-line flags:
Iterative server (default) — one request at a time
-f — Fork-per-request: each incoming request handled by its own child process.
Included proper waitpid() handling to avoid zombies.
-t — Thread-per-request: each connection handled by a dedicated pthread.
-p — Thread pool: A pool of 5 worker threads handles all incoming connections.
Accept loop protected by mutex to avoid simultaneous accept() calls.
Directory Browsing
If the requested path is a directory, the server dynamically generates an HTML page containing:
Hyperlinks to each file/subdirectory
File sizes
Modification timestamps
Sort controls (name / size / time)
CGI-Bin Support
Requests to /cgi-bin/<script> fork a child process that executes the script with: