How babayagaboy/42-webserv works
Webserv is a poll-driven C++98 HTTP server, accompanied by a React file-management demo. The main server workflow is configuration loading, listening and client polling, request parsing/routing, method handling, then response generation; configured routes also enable CGI and upload behavior. The frontend browses, inspects, creates, edits, and deletes files through HTTP requests. Internal control-flow details are limited where source was not sampled; those links are omitted or marked unverified.
Main entry points: ServerConnection.cpp Client connections · main.cpp Webserv · configFile.cpp Config loading · RequestHandlers.cpp Method handlers
Components 28
Configuration
- Config loading
src/config/configFile.cpp - Directive validation
src/config/keyWordsFunc.cpp - Server settings
src/config/ServerConf.cpp - Route settings
src/config/Location.cpp
Server Runtime
- Webserv
src/app/main.cpp - Poll loop
src/server/Server.cpp - Client connections
src/server/ServerConnection.cpp - Client state
src/server/Client.cpp - Sessions
src/server/ServerSession.cpp - Request bodies
src/server/RequestBodyParsing.cpp - CGI execution
src/server/ServerCgi.cpp - Served files
www/simple/files/main.cpp
HTTP Processing
- HTTP parsing
src/http/HTTPrequest.cpp - Route and method dispatch
src/http/RequestDispatch.cpp - Method handlers
src/http/RequestHandlers.cpp - Request support
src/http/RequestSupport.cpp - Response building
src/server/ServerResponse.cpp - HTTP responses
src/http/HTTPresponse.cpp
File Manager Demo
- Frontend routes
frontend/src/App.jsx - Navigation
frontend/src/components/Navbar.jsx - Theme selection
frontend/src/components/ThemeSelector.jsx - File browser
frontend/src/pages/Files.jsx - File editor
frontend/src/pages/FileEditor.jsx - Method inspector
frontend/src/components/MethodInspector.jsx - File API client
frontend/src/lib/files.js - File operations
www/simple/bin/list_files.py - Demo scripts
www/simple/scripts/app.js
Other components
- Browser user
Connections 30
- Browser user → Frontend routes: uses
frontend/src/App.jsx - Frontend routes → File browser: routes to
frontend/src/App.jsx - Frontend routes → File editor: routes to
frontend/src/App.jsx - Frontend routes → Navigation: renders
frontend/src/App.jsx - Navigation → Theme selection: renders
frontend/src/components/Navbar.jsx - File browser → File API client: calls
frontend/src/pages/Files.jsx - File editor → File API client: calls
frontend/src/pages/FileEditor.jsx - File browser → Method inspector: renders
frontend/src/pages/Files.jsx - Browser user → Webserv: sends requests
- Webserv → Config loading: loads config
- Config loading → Directive validation: validates directives
- Config loading → Server settings: builds settings
- Config loading → Route settings: builds routes
- Webserv → Poll loop: starts runtime
- Poll loop → Client connections: polls clients
- Client connections → Client state: tracks clients
- Client connections → HTTP parsing: receives requests
- Client connections → Request bodies: reads bodies
- HTTP parsing → Route and method dispatch: dispatches request
- Route and method dispatch → Method handlers: selects method
- Method handlers → Request support: uses helpers
- Method handlers → Served files: serves or changes
- Client connections → Sessions: manages sessions
- Client connections → CGI execution: runs configured CGI
- CGI execution → HTTP responses: converts CGI output
- Method handlers → Response building: produces response
- Response building → HTTP responses: formats response
- File API client → Webserv: HTTP requests
- Webserv → File operations: routes requests
- Demo scripts → File operations: calls scripts