How khadijalamachi/webserv works
webserv is a custom, non-blocking HTTP/1.1 server. Its main workflow accepts client connections in a poll loop, buffers and parses requests, selects server/location configuration, dispatches the configured operation, and sends a response while deciding whether to keep the connection open. The graph also preserves configuration, CGI, static content, uploads, deletion, directory listings, and error-page capabilities documented in the README. Internal call wiring is shown only where the README or sampled source supports it; unsampled implementation details are not inferred.
Main entry points: server.cpp Poll server · handleResponse.cpp Response dispatcher · parseDirectives.cpp Directive parser · ServerConf.cpp Server config model
Components 18
Configuration
- Server config
configs/def.conf - Directive parser
srcs/parseDirectives.cpp - Server config model
srcs/ServerConf.cpp - Location config
srcs/LocationConf.cpp
HTTP Runtime
- Poll server
srcs/server.cpp - Client buffers
srcs/client.cpp - Request parser
srcs/parseHttpRequest.cpp - HTTP utilities
srcs/httpUtils.cpp
Request Handling
- Host and location matching
srcs/response/config_utils.cpp - Response dispatcher
srcs/response/handleResponse.cpp - Method handlers
srcs/response/methodsHandler.cpp - Response finalization
srcs/response/handleResponse.cpp - HTTP response
srcs/response/response.cpp
CGI Execution
- CGI setup
srcs/cgi/cgi_handler.cpp - Async CGI I/O
srcs/cgi/cgi_server.cpp
Content and Errors
- Static files and uploads
www - Custom error pages
errors
Other components
- HTTP client
Connections 18
- HTTP client → Poll server: sends requests
README.md - Poll server → Client buffers: buffers client I/O
README.md - Poll server → Request parser: passes request bytes
README.md - Request parser → Poll server: returns parsed request
README.md - Poll server → Response dispatcher: dispatches request
README.md - Server config → Directive parser: provides directives
README.md - Directive parser → Server config model: builds configuration
- Server config model → Location config: stores locations
- Response dispatcher → Host and location matching: matches host and location
README.md - Response dispatcher → Method handlers: dispatches file methods
README.md - Method handlers → Static files and uploads: serves or changes files
README.md - Response dispatcher → CGI setup: starts matching CGI
README.md - CGI setup → Async CGI I/O: runs script asynchronously
README.md - Async CGI I/O → Response finalization: finalizes after script exits
README.md - Response dispatcher → Response finalization: finalizes non-CGI results
README.md - Response finalization → Custom error pages: uses configured error page
README.md - Response finalization → HTTP response: builds response
- HTTP response → Poll server: writes response to client
README.md