Skip to content

zinebac/webserv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebServ

WebServ is a custom HTTP server implementation developed as a team project. This server is designed to handle HTTP requests, demonstrating core concepts of web server functionality, network programming, and HTTP protocol implementation.

Project Grade

Table of Contents

  1. Project Overview
  2. Features
  3. Technology Stack
  4. Installation
  5. Usage
  6. Project Structure
  7. Key Concepts
  8. Team Contributions
  9. Resources and Further Reading
  10. License

Project Overview

WebServ is a lightweight HTTP server that implements core functionalities of the HTTP/1.1 protocol. It's designed to handle web serving tasks, demonstrating the fundamental principles of network programming, concurrent connections handling, and HTTP request/response cycle management.

Features

  • HTTP/1.1 protocol support
  • GET, POST, and DELETE method handling
  • Static file serving
  • Custom error pages
  • CGI support
  • Connection multiplexing using poll()
  • Config file parsing for server setup
  • Multiple virtual servers support

Technology Stack

  • Language: C++
  • Network Programming: POSIX sockets
  • I/O Multiplexing: poll() system call
  • Build System: Makefile
  • CGI: PHP and Python support

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/webserv.git
    
  2. Navigate to the project directory:
    cd webserv
    
  3. Compile the project:
    make
    

Usage

  1. Run the server with a configuration file:

    ./webserv <config_file>
    

    Example configuration files are provided in the config_files/ directory.

  2. Access the server through a web browser or tools like curl:

    curl http://localhost:<port>
    
  3. To stop the server, use Ctrl+C or any interrupting signal.

  4. To clean up compiled files:

    make fclean
    

Project Structure

webserv/
├── Headers/
│   ├── Cgi.hpp
│   ├── Libraries.hpp
│   ├── WebServerIncludes.hpp
│   └── ConfigFileParsing/
│       ├── ConfigFile.hpp
│       ├── Location.hpp
│       └── ServerConfig.hpp
├── Parsing/
│   ├── Location.cpp
│   ├── ServerConfig.cpp
│   ├── Utils.cpp
│   ├── config_file.cpp
│   └── overload_operator.cpp
├── config_files/
│   ├── aababach.conf
│   ├── gkarib.conf
│   └── zait-che.conf
├── httpServer/
│   ├── Network.cpp
│   ├── cgi.cpp
│   ├── generators.cpp
│   ├── getters.cpp
│   ├── helpers.cpp
│   ├── httpServer.cpp
│   ├── post.cpp
│   └── setters.cpp
├── src/
│   ├── favicon.ico
│   ├── cgi/
│   │   ├── cookie_setter.php
│   │   ├── counter.php
│   │   ├── error_py.py
│   │   ├── helloworld.php
│   │   ├── helloworld.py
│   │   ├── infinite_loop.php
│   │   ├── info.php
│   │   └── query.php
│   ├── cgi_bin/
│   │   ├── php-cgi
│   │   └── py-cgi
│   ├── errors/
│   │   ├── 400.html
│   │   ├── 403.html
│   │   └── ... (other error pages)
│   ├── home/
│   │   ├── index.html
│   │   ├── lacost.html
│   │   ├── larini.html
│   │   └── ... (other assets)
│   └── media/
│       ├── en.subject.pdf
│       └── notes
├── Makefile
└── README.md

Key Concepts

Sockets

Sockets are the fundamental building blocks for network communication. In WebServ, we use POSIX sockets to create TCP connections.

Multiplexing with poll()

The server uses the poll() system call and its helper functions to handle multiple client connections concurrently. This allows the server to efficiently manage numerous connections without the need for multi-threading.

HTTP Protocol

Our server implements key aspects of HTTP/1.1, including:

  • Request parsing
  • Response formatting
  • Header handling
  • Status codes
  • GET, POST, and DELETE methods

CGI (Common Gateway Interface)

Our implementation provides CGI support for both PHP and Python, enabling the execution of scripts and returning their output as part of the HTTP response.

Configuration System

The server uses a custom configuration file system, allowing for easy setup of multiple virtual servers and locations.

Team Contributions

  • zait-che (Me):

    • GET and DELETE method implementation
    • Request parsing and data structure design
    • Response sending mechanism
    • Multiplexing support
    • Static and error page handling
  • aababach:

    • Multiplexing implementation using poll()
    • POST method implementation
    • Custom request parsing and response sending method
  • gkarib:

    • Configuration file parsing
    • CGI implementation

Resources and Further Reading

License

This project is licensed under a restrictive, custom license. See the LICENSE file for details. Unauthorized use, modification, or distribution of this software is strictly prohibited.

About

A lightweight HTTP server from the 42 School curriculum.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published