How ahmadmnsur/42_webserv works
WebServ is a C++ HTTP server. The principal workflow is configuration loading, listening for connections, parsing and routing requests, then producing HTTP responses through method-specific handlers and file/CGI services. Separate branches provide session and cookie APIs. The README documents the broader protocol and file-serving capabilities; source excerpts are partial, so edges are limited to documented or indexed relationships rather than inferred runtime calls.
Main entry points: ConfigParser.cpp Config parser · ConnectionHandler.cpp Connection handler · WebServer.cpp Web server · RequestProcessor.cpp Request processing
Components 26
Configuration
- Config parser
src/config/ConfigParser.cpp - Config tokenizer
src/config/ConfigTokenizer.cpp - Config validator
src/config/ConfigValidator.cpp - Server settings
src/config/ServerConfig.cpp - Location rules
src/config/Location.cpp
Server Runtime
- Server entry
src/core/main.cpp - Web server
src/core/WebServer.cpp - Signal handling
src/core/SignalHandler.cpp - Socket manager
src/network/SocketManager.cpp - Connection handler
src/network/ConnectionHandler.cpp - Client state
src/core/ClientData.cpp
HTTP Processing
- Request processing
src/http/RequestProcessor.cpp - Processor factory
src/http/HttpProcessorFactory.cpp - HTTP request
src/http/HttpRequest.cpp - HTTP response
src/http/HttpResponse.cpp
File and CGI
- GET handler
src/http/GetHttpProcessor.cpp - POST handler
src/http/PostHttpProcessor.cpp - DELETE handler
src/http/DeleteHttpProcessor.cpp - CGI execution
src/http/IHttpProcessor.cpp - File operations
src/utils/FileHandler.cpp
Sessions and Cookies
- Session API
src/http/SessionApiHandler.cpp - Session handling
src/http/SessionHandler.cpp - Session store
src/http/SessionManager.cpp - Cookie API
src/http/CookieApiHandler.cpp - Cookie handling
src/http/CookieManager.cpp
Other components
- HTTP client
Connections 28
- HTTP client → Server entry: sends requests
README.md - Server entry → Config parser: parses config
src/core/main.cpp - Server entry → Web server: starts server
src/core/main.cpp - Config parser → Config tokenizer: uses tokens
- Config parser → Config validator: validates config
- Config parser → Server settings: builds settings
- Config parser → Location rules: builds locations
- Web server → Signal handling: handles shutdown
- Web server → Socket manager: manages sockets
- Web server → Connection handler: dispatches connections
- Connection handler → Client state: tracks clients
- Connection handler → Request processing: processes requests
- Connection handler → HTTP request: parses requests
- Connection handler → HTTP response: sends responses
- Request processing → Processor factory: selects handler
- Processor factory → GET handler: selects GET
README.md - Processor factory → POST handler: selects POST
README.md - Processor factory → DELETE handler: selects DELETE
README.md - GET handler → File operations: serves files
README.md - GET handler → CGI execution: runs CGI
README.md - POST handler → File operations: handles uploads
README.md - Request processing → Session API: routes API
- Request processing → Cookie API: routes API
- Session API → Session store: manages sessions
- Session handling → Session store: manages sessions
src/http/SessionHandler.cpp - Session handling → Cookie handling: uses cookies
src/http/SessionHandler.cpp - Cookie API → Cookie handling: manages cookies
- Session API → Cookie handling: uses cookies