How devdha/webserv works
Project type and purpose
• This is a standalone HTTP web‐server (“webserv”) written in C++. It reads configuration files, listens on one or more sockets, parses HTTP requests, dispatches them to either static file serving or CGI executables, constructs HTTP responses, logs activity, and sends responses back to clients.
File structure
• Top‐level:
• config/ : server‐ and location‐level configuration files (.conf)
• / : all public headers (Parser, Scanner, Config*, Server, Processor, CgiHandler, FileManager, etc.)
• src/ : implementation (.cpp), including main.cpp which spins up Webserv
• practice/ : sample socket/select code snippets (prototype / experimentation)
• test/ : CGI and end‐to‐end testers
• www/ : sample document root (static files, directories, CGI results)
• Key patterns: single process, event‐driven (select‐based) reactor, modular separation (Config loader → Server objects → Connection / Request / Response modules → CGI or static).
Additional notes
Layer 1: Clients
Layer 2: Network / Reactor
Layer 3: Webserv Core (Config, Parser, Processor)
Layer 4: Resources (File System, CGI scripts)
Layer 5: Logging / Monitoring
• Concurrent or blocking points (e.g., fork/exec in CgiHandler)