A lightweight Linux-based multithreaded WebServer. This project is mainly for learning and practice.
- HTTP/1.0 and HTTP/1.1: GET only
- Supports
.cgifiles and one environment variable - Supports static file responses
- Supports 404 page handling
- Fixed-size thread pool for request handling
- Main thread responsible for
accept - Worker threads responsible for HTTP request processing
- Built with Makefile
- Bash-based CI automated testing
- Modular directory structure
- Supports stress testing
.
├── .github/
├── bin/ #.gdbinit here & files for server
├── include/
├── src/
├── tests/ # Test scripts and examples
├── .clang-format
├── .gitignore
├── Makefile
├── Project.md
└── README.md
- Linux
- gcc
- make
Recommended:
- Arch Linux
- gcc 16+
makeExample:
./wserver -d ./basedir/ -p 8003 -t 8 -b 16 -s FIFOParameter descriptions:
| Parameter | Meaning |
|---|---|
-p |
Listening port |
-d |
Root directory |
-t |
Number of threads |
-b |
Number of buffers |
-s |
Scheduling policy |
In a browser:
http://127.0.0.1:port/a.html
Or:
./wclient localhost 8003 /notfind.htmlParameter description:
Usage: ./wclient <host> <port> <filename>
Run the CI tests:
make testTest coverage includes:
- Static file tests
- CGI tests
- 404 tests
- Concurrent request tests (static and
.cgifiles)
Current goals:
- Return static files in single-threaded mode
- Return
.cgiprocessing results in single-threaded mode - Return static files in multithreaded mode
- Return
.cgifiles in multithreaded mode - Support SFF (theoretically supported, not yet tested)
This project is well suited for learning:
- Linux system programming
- Socket network programming
- HTTP protocol
- Reactor model
- High-performance servers
MIT License