This is when you finally understand why a URL starts with HTTP.
This project is about writing a non-blocking HTTP/1.1 server in C++, designed to handle multiple simultaneous connections efficiently using asynchronous I/O. The server adheres to the HTTP/1.1 protocol and supports essential features such as GET, POST, DELETE, and error handling, ensuring responsive communication without stalling the main execution thread. Additionally, the server integrates non-blocking CGI execution, supporting various languages such as Python, Perl, PHP, and binary executables. Multi threading implementation, each server instance runs on its own thread.
make run
It will automatically compile the project and run it.
./webserv [configuration file]
Will launch the previously compiled project with make
and run it. (configuration file must be a valid .conf
file see section below)
It will allow you to setup the following parameters :
name
-- define the server namelisten
:port
-- to configure on which port the server will be listening (only onelisten
perserver
block)methods
-- to set the authorized HTTP request (GET
|POST
|DELETE
)location
-- to set parameters for a specific routeindex
-- to serve a default file if none match the requested URIroot
-- to route the requested URI to another directoryupload
-- to set a specific directory for upload requestslisting
-- to list all files present in the targeted directory (ON
|OFF
)error
-- to define the page to display when an error occurs, add a default page if none is provided in the.conf
file.cgi
-- to configure a cgi to execute for a specific file extenstion (.php
|.py
|.pl
)redirection
-- to define a redirection to a location or to an another server
{
name server
listen 0.0.0.0:8080
methods GET POST
body_size 1000000000000
root ./rsrcs
upload /upload
index index.html
error 404 404.html
location /cookie
root ./rsrcs/cookie
index cookie.html
methods GET
location /cgi
root ./rsrcs/cgi
listing ON
cgi .py .php
methods GET POST
location /intra
root ./rsrcs/intra
index intra.html
methods GET
location /listing
listing ON
error 403 403.html
error 404 404.html
root ./rsrcs/listing
methods GET
location /listing/403.html
root ./rsrcs/listing/403.html
location /listing/404.html
root ./rsrcs/listing/404.html
location /listing/1/2/3
redirection /listing
location /upload
root ./rsrcs/upload
methods GET DELETE
location /redirection
redirection https://fr.wikipedia.org/
}
-
Configuration Flexibility
-- Accepts a custom configuration file or defaults to a predefined path -
Non-Blocking Architecture
-- Uses a singleselect()
(or equivalent) per server for all I/O operations, including listening and client communication -
Efficient Resource Management
-- Handles all read/write operations viaselect()
, optimizing resource usage and preventing blocking -
HTTP Methods
-- SupportsGET
,POST
, andDELETE
-
File Uploads
-- Allows clients to upload files directly to the server -
Static File Serving
-- Serves static websites -
Accurate HTTP Responses
-- Delivers precise status codes along with a specified error page or a default one -
CGI Integration
-- Supports CGI execution (e.g.,PHP
,Python
,Perl
, ...) -
Multi-Port Listening
-- Listens on multiple ports as defined in the configuration file -
Browser Compatibility
-- Compliant with HTTP 1.1 standards. -
Handle Cookies
-- A small cookie clicker has been made to show the implementation of the cookies -
Keep-alive connection
-- Connection is kept alive if possible -
Time out
-- Timeout for CGI and basic requests
This group project was done by MVPee (mvan-pee) and Dan (dspilleb)