By @cpeset-c & @alajara- & pramos-m
- Description
- Features
- Prerequisites
- Installation
- Usage
- Configuration File
- Performance
- Contributing
- HTTP Request Handling
- Known Issues
- License
- Documentation
- Acknowledgments
This WebServer project is a simple yet robust HTTP server built from scratch. It is designed to parse configuration files, manage HTTP requests, and serve files over the network. The project is divided into three main components:
-
Configuration File Parser: The server can be launched with a default configuration or by specifying a custom configuration file. The parser reads and processes the configuration file to set up the
ConfigData
object, which holds all necessary server settings. -
Web Server Core: The core of the server handles the initialization, management, and termination of the web server. It ensures that requests are processed in an efficient manner, manages data queues, and gracefully closes connections to prevent file descriptor leaks.
-
HTTP Request Handler: This component parses incoming HTTP requests, transforming them into manageable data structures. It also prepares and sends HTTP responses based on the parsed requests.
- Customizable Configuration: Launch the server with a default or custom configuration file.
- HTTP Request Parsing: Supports parsing of standard HTTP requests into structured data.
- Efficient Data Management: Manages incoming requests through a queue to ensure smooth handling and processing.
- Graceful Shutdown: Closes all resources, including file descriptors, to prevent resource leaks.
- Error Handling: Basic error handling and reporting for common server issues.
- Loging Data: Basic logger for the server. Logs everything to .log file
-
Requirements for MacOS:
- clang
- make
- C++98 or later
-
Requirements for Linux:
- gcc
- make
- C++98 or later
- Clone the repository:
git clone https://github.com/YourUsername1/webserver.git webserver
- Access the cloned directory:
cd webserver
- Build the project:
make
-
Run the WebServer executable:
./webserv
Or specify a custom configuration file:
./webserv path/to/file.conf
Replace
path/to/file.conf
with the path to your configuration file. -
The server will start and listen for incoming HTTP requests.
The server uses a configuration file to set up various parameters like the port, server root directory, and other settings. Refer to the provided default.conf
file for an example.
The WebServer has been optimized for performance:
- Asynchronous I/O: The server uses non-blocking I/O operations to handle multiple requests concurrently.
- Memory Management: Efficient memory allocation and deallocation to avoid leaks and minimize overhead.
- Benchmarking: The server has been tested under
siege
utility.
Example:
siege --benchmark --time=30s http://localhost:8080
Encourage collaboration by outlining how others can contribute to the project.
We welcome contributions to the WebServer project! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
).- Make your changes.
- Ensure your changes pass existing tests and add new tests if necessary.
- Submit a pull request with a detailed description of your changes.
The server is capable of handling standard HTTP requests such as GET
, POST
, and DELETE
. Requests are parsed into a structured format that the server can manage, and responses are prepared based on the request data.
- File Descriptor Management: Ensure that no file descriptors are left open after server termination.
- Error Logging: Basic error logging is implemented, but further enhancements are planned.
- Poor Config File Configuration: Basic config file is implemented, but further enchancements would be great; like variable enviroment, and more features.
- Expand on the I/O Multiplexing: Check and implement new code for the server multiplexing, and implement an algorith queue for the server to increment avaibility.
- Bad Http Class: Redo the Http class, wich currently implement the data parsing, data transformation and request maker.
This project is licensed under the MIT License.
For more detailed documentation on how the WebServer works, please refer to:
Each module is thoroughly documented to assist developers in understanding and extending the server's capabilities.
- Inspired by Nginx for its efficient and modular design.
- ...