How nhmikami/42-webserv works
Webserv is a C++98 HTTP/1.1 server. Its principal workflow is to load server configuration, accept non-blocking client connections through a poll-based loop, parse and validate requests, route them to method handling or CGI, build responses, and write them back. The graph also preserves documented static-file, directory-listing, upload, error-page, virtual-server, and session/cookie capabilities. Relationships are based on the README’s architecture and feature descriptions plus the sampled declarations; implementation-level wiring is not fully shown.
Main entry points: Server.cpp Poll server · ParseHttp.cpp HTTP parser · Client.cpp Client connection · AMethod.cpp GET POST DELETE
Components 18
Server runtime
- Poll server
src/server/Server.cpp - Client connection
src/server/Client.cpp
HTTP handling
- HTTP parser
src/parse/ParseHttp.cpp - Header validation
src/parse/ParseHttpValidator.cpp - URI parsing
src/parse/ParseUri.cpp - Cookie parsing
src/parse/ParseCookie.cpp - HTTP request
src/http/Request.cpp - GET POST DELETE
src/http/AMethod.cpp - HTTP response
src/http/Response.cpp
Configuration
- Config parser
src/config/ParseConfig.cpp - Virtual server config
src/config/ServerConfig.cpp - Location config
src/config/LocationConfig.cpp
Response features
- Files and listings
src/utils/FileUtils.cpp - CGI execution
src/server/CgiHandler.cpp - Session manager
src/server/SessionManager.cpp - Session state
src/server/Session.cpp
Other components
- Server operator
- CGI scripts
Connections 18
- Server operator → Config parser: provides config
- Config parser → Poll server: configures
- Poll server → Client connection: accepts clients
- Client connection → HTTP parser: feeds request data
- HTTP parser → Header validation: validates headers
- HTTP parser → URI parsing: parses target
- HTTP parser → Cookie parsing: parses cookies
- HTTP parser → HTTP request: builds request
- Poll server → Virtual server config: selects config
- Virtual server config → Location config: defines locations
- Poll server → GET POST DELETE: routes methods
- Poll server → CGI execution: dispatches CGI
- CGI execution → CGI scripts: executes scripts
- Poll server → HTTP response: builds response
- GET POST DELETE → Files and listings: serves files
- HTTP response → Client connection: writes to socket
- Poll server → Session manager: manages sessions
- Session manager → Session state: stores sessions