Webserv
An HTTP/1.1 server written from scratch in C++, built to understand the machinery below familiar web frameworks.
- Role
- Systems design, HTTP implementation, networking, and test-driven debugging.
- Stack
- C++ / Linux / Networking / HTTP / CGI
Overview
The web stack, reduced to sockets, bytes, state, and careful failure handling.
An HTTP/1.1 server written from scratch in C++, built to understand the machinery below familiar web frameworks.
The constraint shaped the system.
A server must handle many partial, malformed, and concurrent requests without blocking or losing protocol correctness.
Responsibilities made explicit.
A non-blocking event loop separates connection state, request parsing, routing, response construction, and resource cleanup into explicit stages.
Request lifecycle
From socket readiness to HTTP response.
Each connection advances through explicit transport, parsing, routing, execution, and response stages without blocking the event loop.
- 01Client
- 02Request parser
- 03Server / location
- 04Static / upload / CGI
- 05Response
- poll() readiness
- Keep-alive
- Range requests
- Sessions
- Timeouts
- Error responses
Engineering
Protocol correctness under concurrency.
- 01
Event loop
poll() tracks socket readiness so multiple connections can progress through partial reads and writes without blocking.
- 02
Routing
Parsed configuration drives server selection and longest-prefix location routing before a response handler is chosen.
- 03
CGI
CGI execution constructs the required environment and is coordinated without stalling unrelated client connections.
- 04
Connection management
Keep-alive, payload limits, and timeouts bound connection work and cleanup.
- 05
HTTP behavior
Uploads, sessions, cookies, Range requests, and explicit error responses extend the core request path.
System scope
- 01HTTP/1.1 parsing
- 02Non-blocking sockets
- 03poll() event loop
- 04Routing & configuration
- 05CGI execution
- 06Uploads
- 07Sessions & cookies
- 08Range requests
- 09Keep-alive & timeouts
- C++
- Linux
- Networking
- HTTP
- CGI
Engineering takeaway
Framework abstractions become much easier to judge after implementing the protocol behavior they hide.