How rgrmra/webserv works
Webserv is a non-blocking C++98 HTTP/1.1 server. Its principal workflow accepts a client request, parses it against configured servers and routes, resolves the target resource, handles the requested method (including static delivery, uploads, deletion, or CGI), and returns an HTTP response. Configuration parsing, URL/resource resolution, and CGI environment setup are distinct domain stages. The README documents major capabilities not fully evidenced by the excerpts; edges for those documented behaviors cite it, while uncertain internal wiring is omitted.
Main entry points: Cgi.cpp CGI execution · Connection.cpp Client connection · WebServ.cpp Socket event loop · Http.cpp HTTP config
Components 21
Server runtime
- Server startup
src/main.cpp - Socket event loop
src/connection/WebServ.cpp - Client connection
src/connection/Connection.cpp
Configuration
- HTTP config
src/parser/configuration/Http.cpp - Server config
src/parser/configuration/Server.cpp - Route config
src/parser/configuration/Location.cpp - Config directives
src/parser/directive.cpp
HTTP handling
- Request parsing
src/parser/request/request.cpp - URL resolution
src/response/URL.cpp - Response builder
src/response/response.cpp - GET handling
src/response/methods/get.cpp - POST handling
src/response/methods/post.cpp - DELETE handling
src/response/methods/delete.cpp
Resources and CGI
- Resource access
src/file/Resource.cpp - File delivery
src/file/File.cpp - Directory listing
src/file/Directory.cpp - CGI execution
src/file/Cgi.cpp - CGI environment
src/file/Environment.cpp
Other components
- HTTP client
- Website files
- CGI interpreter
Connections 24
- HTTP client → Socket event loop: sends requests
- Server startup → HTTP config: loads config
src/main.cpp - Socket event loop → HTTP config: reads listeners
src/connection/WebServ.cpp - Socket event loop → Client connection: accepts clients
src/connection/WebServ.cpp - Socket event loop → Client connection: dispatches I/O
src/connection/WebServ.cpp - HTTP config → Server config: holds servers
- Server config → Route config: holds routes
- Config directives → HTTP config: parses directives
- Config directives → Server config: parses directives
src/parser/configuration/Server.cpp - Config directives → Route config: parses directives
- Client connection → Request parsing: parses request
src/connection/Connection.cpp - Client connection → URL resolution: resolves target
src/connection/Connection.cpp - Client connection → Response builder: builds response
src/connection/Connection.cpp - GET handling → File delivery: serves files
src/response/methods/get.cpp - GET handling → Directory listing: lists directories
src/response/methods/get.cpp - GET handling → CGI execution: starts CGI
src/response/methods/get.cpp - POST handling → Website files: accepts uploads
- DELETE handling → Website files: deletes resources
- File delivery → Website files: reads content
- Directory listing → Website files: lists contents
- CGI execution → CGI environment: builds environment
src/file/Cgi.cpp - CGI execution → CGI interpreter: executes script
src/file/Cgi.cpp - CGI execution → Response builder: builds response
src/file/Cgi.cpp - CGI execution → HTTP client: returns output