Giter Site home page Giter Site logo

yismaili / webserv Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 185.97 MB

This project is here to make you write your own HTTP server

C++ 74.81% Makefile 0.45% HTML 20.52% PHP 1.66% Python 1.20% CSS 1.36%
http-server webserv http-requests http-response socket-programming

webserv's Introduction

webserv

Webserv is a C++ 98 HTTP server that implements the Hypertext Transfer Protocol (HTTP) standards. It allows storing, processing, and delivering web pages to clients while adhering to the specified requirements. The server is designed to be non-blocking, ensuring optimal performance and compatibility with web browsers. In addition to the mandatory features, there is also an opportunity to implement bonus features such as cookies and session management.

Requirements

Description

  • The server should be a fully functional HTTP server implemented in C++ 98.
  • The program should take a configuration file as an argument or use a default path if none is provided.
  • The server must not block, and the client should be handled appropriately if necessary.
  • Non-blocking I/O operations should be implemented using a single poll() or equivalent function.
  • The poll() or equivalent function should check both read and write operations simultaneously.
  • All read and write operations should go through the poll() or equivalent function, and checking the value of errno after a read or write operation is strictly forbidden.
  • Reading the configuration file does not require using poll() or equivalent function.
  • Macros and defines such as FD_SET, FD_CLR, FD_ISSET, and FD_ZERO can be used.
  • Requests to the server should not hang indefinitely.
  • The server should be compatible with a chosen web browser, and its HTTP response status codes should be accurate.
  • Default error pages should be provided if none are specified.
  • The use of fork should be limited to CGI (Common Gateway Interface) implementations, such as PHP or Python.
  • The server should be able to serve a fully static website.
  • The server should support the GET, POST, and DELETE methods.
  • Stress testing of the server is required to ensure its availability under heavy load.
  • The server should be able to listen on multiple ports as specified in the configuration file.

For macOS Only

  • Since macOS implements write() differently from other Unix operating systems, the use of fcntl() is allowed.
  • File descriptors should be set to non-blocking mode using the following code: fcntl(fd, F_SETFL, O_NONBLOCK). Any other flag for fcntl() is forbidden.

Configuration File

  • The configuration file should resemble the 'server' part of an NGINX configuration file.
  • The configuration file should allow the following:
  • Specifying the port and host for each 'server'.
  • Setting up server names.
  • Assigning a default server for a host:port combination.
  • Configuring default error pages.
  • Limiting client body size.
  • Setting up routes with the following rules/configurations (regular expressions are not used):
  • Defining a list of accepted HTTP methods for the route.
  • Setting up HTTP redirection.
  • Specifying a directory or file to search for requested files.
  • Enabling or disabling directory listing.
  • Setting a default file to serve if the request is for a directory.
  • Executing CGI based on file extensions.
  • Supporting POST and GET methods.
  • Allowing routes to accept uploaded files and configuring the storage location.

Bonus Part

The following bonus features can be added:

  • Support for cookies and session management.
  • Handling multiple CGI implementations.

webserv's People

Contributors

aoumad avatar snouae avatar yismaili avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

aoumad snouae

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.