8000 GitHub - ElPatatin/webserv
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ElPatatin/webserv

Repository files navigation

WebServer Project

The webserv project is a very simple, fast and light weight web server made in c++. By @cpeset-c & @alajara- & @pramos-m

Table of Contents

  1. Description
  2. Features
  3. Prerequisites
  4. Installation
  5. Usage
  6. Configuration File
  7. Performance
  8. Contributing
  9. HTTP Request Handling
  10. Known Issues
  11. License
  12. Documentation
  13. Acknowledgments

Description

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:

  1. 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.

  2. 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.

  3. 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.

Features

  • 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

Prerequisites

  • Requirements for MacOS:

    • clang
    • make
    • C++98 or later
  • Requirements for Linux:

    • gcc
    • make
    • C++98 or later

Installation

  1. Clone the repository:
    git clone https://github.com/YourUsername1/webserver.git webserver
  2. Access the cloned directory:
    cd webserver
  3. Build the project:
    make

Usage

  1. 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.

  2. The server will start and listen for incoming HTTP requests.

Configuration File

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.

Performance

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

Contributing

Encourage collaboration by outlining how others can contribute to the project.

Contributing

We welcome contributions to the WebServer project! To contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Ensure your changes pass existing tests and add new tests if necessary.
  5. Submit a pull request with a detailed description of your changes.

HTTP Request Handling

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.

Known Issues

  • 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.

License

This project is licensed under the MIT License.

Documentation

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.

Acknowledgments

  • Inspired by Nginx for its efficient and modular design.
  • ...

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0