How victra15/webserv works
Project type and purpose
• This is a standalone, C++-based HTTP/1.1 server implementing socket I/O multiplexing (kqueue on macOS), configuration parsing, static file serving, CGI execution, and basic HTTP methods (GET, POST, DELETE).
File structure
• Top-level executables and scripts:
• cgi/php-cgi (actual PHP CGI binary)
• var/ (test HTML, PHP, Python CGI scripts and resources)
• conf/ (server configuration files)
• error_page/ (custom error pages)
• Core C++ code:
• / (public headers: ConfigInfo, HTTPRequest/Response, ServerHandler, LocationConfig, utils)
• srcs/ (corresponding .cpp implementations and main webserv.cpp)
• Build and run:
• Makefile, .gitignore
Additional README insights
• Uses Reactor pattern via kqueue for non-blocking, event-driven I/O.
• Components split into:
• ServerHandler (socket setup, event loop)
• ConfigInfo + LocationConfig (parsing .conf into in-memory server & location blocks)
• HTTPMessage / HTTPRequest / HTTPResponse (parsing, serializing)
• CGI integration (spawn external processes)
• Static file I/O and autoindex
Detail
• Eight client states (RECV_HEADER, RECV_BODY, GET, POST, DELETE, MAKE_RESPONSE, MAKE_CGI_RESPONSE, SEND_RESPONSE) as sub-steps or annotations around the Reactor component
• How configuration (conf/*.conf) flows into ConfigInfo → LocationConfig and informs routing rules, allowed methods, CGI mappings, error pages, and root directories