This project is a complete lightweight HTTP server built from scratch in C++. It supports basic HTTP methods and extends into advanced web features through modular and well-structured code. This server was developed as a comprehensive hands-on learning project and is suitable for showcasing on resumes and GitHub.
- β
Non-blocking socket server using
select()
for I/O multiplexing - β Custom HTTP request parsing (supports GET, POST, DELETE)
- β
Static file serving from the
/public
directory - β Cookie-based login and logout functionality with expiration tracking
- β File upload using multipart/form-data via POST requests
- β
Download most recently uploaded file (
/download
endpoint) - β CGI script execution for dynamic content (GET/POST)
- β Cookie store with in-memory session expiration
- β Thread Pool for concurrent client request processing
- β Auto-cleanup of old uploaded files after a timeout
.
βββ include/
β βββ http_request.h
β βββ utils.h
β βββ ThreadPool.h
βββ src/
β βββ main.cpp
β βββ http_request.cpp
β βββ utils.cpp
β βββ ThreadPool.tpp
βββ public/
β βββ index.html
β βββ upload.html
β βββ uploaded_file.txt/pdf <-- dynamically created
βββ cgi-bin/
β βββ env.py
β βββ post_echo.py
βββ Makefile
βββ README.md
make clean
make
./server
curl http://localhost:8080/
curl http://localhost:8080/upload.html
curl -X POST http://localhost:8080/echo -d "name=John&age=30"
echo "This is a test file." > test_upload.txt
curl -X POST http://localhost:8080/upload -F "file=@test_upload.txt"
curl -O http://localhost:8080/download
curl -i "http://localhost:8080/set-cookie?name=John"
curl -b "username=John" http://localhost:8080/get-cookie
curl -c cookies.txt "http://localhost:8080/login?user=Sam"
curl -b cookies.txt http://localhost:8080/profile
curl -b cookies.txt -c cookies.txt http://localhost:8080/logout
curl -b cookies.txt http://localhost:8080/profile
curl "http://localhost:8080/cgi-bin/env.py?foo=bar&user=test"
curl -X POST http://localhost:8080/cgi-bin/post_echo.py -d "x=5&y=10"
curl -X DELETE http://localhost:8080/uploaded_file.txt
seq 10 | xargs -n1 -P10 curl -s http://localhost:8080/upload.html > /dev/null
- Add persistent file tracking instead of single
uploaded_file.txt
- Add full multipart/form-data parser for filenames and types
- Implement async I/O using
epoll
or Boost ASIO (Linux) - Add HTTPS support
Β© Developed as a full-stack systems project in C++