Webserv is a simple HTTP server written in C++, it supports HTTP/1.1 and many of its features such as connection keep-alive, chunked transfer-encoding, multipart/form-data, and more... It uses a single threaded non blocking event loop, allowing it to handle many requests simultaneously.
Webserv is built using C++98, latest c++ versions or external libraries (even Boost) were not allowed.
The webserver handles static files, file upload via multipart form data and CGI scripts (Python, PHP, Perl...)
My contribution to this project involved implementing request parsing, as well as generating and sending responses, the most challenging part was parsing the requests particularly chunked transfer-encoding and multipart-form/data bodies which I handled using state machines, parsing and keeping a state of each request depending on the received chunks (stream parsing) for an efficient and robust parsing. However the handling of large file (both file upload and get requests) was also tricky since an improper implementation could block the thread hence block all other requests, the solution for file upload was to implement in memory storage for files less than a threshold (I set to 2mb) larger files would be stored directly in files and sent chunk by chunk, while handling other requests, sending large files was solved by implementing a ring buffer, keeping only a part of the file in memory and sending it while handling other requests.
This project was very interesting, I was eager to work on it since I joined the school, I have always used web servers, but I never fully understood how it works under the hood. It introduced me to event-driven architectures (for example, javascript works kind of the same way for handling IO asynchronously via an event loop) and stream parsing, it also required robust error management, the webserver should never crash.