How kj-rollin/httpserver works
This is a multithreaded C++ HTTP/1.1 server for user registration, login, and job-application file submissions and management. The main workflow accepts a browser request, applies per-IP limiting, dispatches it to a route or static-file handler, and returns a response. Handlers implement authentication, session/CSRF checks, uploads, and application operations, using SQLite for persistent records. The README documents compression, caching, and security features; sampled code supports the cache/compression and session paths, but the handler excerpts are incomplete, so uncertain route wiring is omitted.
Main entry points: handlers.h Route handlers · main.cpp Socket server · router.h Router · cache.h Static file cache
Components 16
Server runtime
- Socket server
main.cpp - Worker pool
threadpool.h - IP rate limiter
rate_limiter.h
HTTP handling
- Router
router.h - Route handlers
handlers.h - HTTP utilities
utils.h - Multipart parser
multipart.h - Static file cache
cache.h - Gzip compression
gzip.h - Web pages
www
Identity and security
- Session manager
session.h - Password and tokens
crypto.h
Application data
- Database wrapper
database.h - SQLite database
- Uploaded files
Other components
- Browser
Connections 19
- Browser → Socket server: sends HTTP
- Socket server → Worker pool: queues request
- Worker pool → Socket server: runs client task
- Socket server → HTTP utilities: parses request
- Socket server → IP rate limiter: checks IP
- Socket server → Router: dispatches request
- Router → Route handlers: dispatches route
- Router → Static file cache: serves static files
- Static file cache → Gzip compression: compresses content
- Static file cache → Web pages: reads files
- Route handlers → HTTP utilities: parses and formats
- Route handlers → Session manager: validates and creates
- Route handlers → Database wrapper: reads and updates
- Route handlers → Multipart parser: parses uploads
- Route handlers → Uploaded files: writes files
- Route handlers → Web pages: renders pages
- Database wrapper → SQLite database: queries
- Database wrapper → Password and tokens: hashes passwords
- Browser → Web pages: views pages