Lightweight HTTP/1.1 server built from scratch in C++ using a custom thread pool.
Demonstration of concurrent clients and gzip compression.
I built this to practice writing high-quality multithreaded C++ and to understand socket-level networking - how requests are parsed, how threads synchronize, and what really happens between recv() and send(). The focus was on clarity, ownership, and performance - not frameworks or abstractions.
The server runs on a simple thread-pool model: one thread accepts connections, workers pop Client objects from a blocking queue and handle them independently. Each client is fully RAII-managed and movable to ensure clean socket teardown and no descriptor leaks under load.
- Concurrency: Custom blocking WorkQueue + thread pool (std::thread, std::condition_variable)
- Compression: GZIP with zlib, automatically used when Accept-Encoding: gzip is set
- Routing: /echo/, /user-agent, and file GET/POST via /files/ (configurable via --directory)
- Safety: Rejects unsafe filenames (../), no shared mutable state
- Build: Standard CMake / Makefile, links against system zlib
mkdir build && cd build
cmake .. && make
./http_server --directory ./publicNext steps are to implement HTTP Keep-Alive for persistent connections and move toward an epoll-based I/O model to explore event-driven concurrency.