This is my toy implementation of an extremely basic http server. Any and all suggestions are welcome.
-
Core Server Layer
- Main Listener: Accepts TCP connections.
- Concurrency: Start with a simple thread-per-connection or thread pool; upgrade to async/event-driven I/O (later).
- SSL/TLS: Add support for HTTPS (later).
-
Request Processing Pipeline
- Parser: Parse incoming HTTP requests into struct, upgrade to a hash map. (later)
- Router: Simple URL mapping to resolve static file paths.
- File I/O: Read files from disk with MIME type detection.
- Encoder: Build and encode HTTP responses.
-
Cross-Cutting Concerns (Low-Hanging Fruit)
- Logging & Monitoring: Log requests, errors, and performance metrics.
- Error Handling: Return proper 404/500 responses.
- Security: Prevent path traversal and implement basic access control.
- Compression: Support gzip/Brotli to reduce payload sizes.
- Caching: In-memory LRU cache for frequently accessed files.
- Directory Indexing: Support for index files or autoindex as needed.
-
Future Enhancements
- Rate Limiting: Mitigate abuse and DoS attacks.
- CDN Integration: Offload and globally cache static assets.