https://github.com/jos-felipe/webserv
This project is here to make you write your own HTTP server. You will be able to test it with a real browser. HTTP is one of the most used protocol on internet. Knowing its arcane will be useful, even if you won't be working on a website.
https://github.com/jos-felipe/webserv
network network-and-system-administration object-oriented-programming rigor unix
Last synced: 6 months ago
JSON representation
This project is here to make you write your own HTTP server. You will be able to test it with a real browser. HTTP is one of the most used protocol on internet. Knowing its arcane will be useful, even if you won't be working on a website.
- Host: GitHub
- URL: https://github.com/jos-felipe/webserv
- Owner: jos-felipe
- Created: 2025-03-20T20:11:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-20T20:45:53.000Z (over 1 year ago)
- Last Synced: 2025-03-20T22:05:53.245Z (over 1 year ago)
- Topics: network, network-and-system-administration, object-oriented-programming, rigor, unix
- Homepage: https://projects.intra.42.fr/projects/webserv
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WebServ - HTTP Server Implementation
## ๐ Overview
WebServ is a lightweight HTTP server implementation in C++98. This project is developed to understand the internals of HTTP protocol and web servers, providing hands-on experience with network programming, concurrent connections handling, and HTTP protocol implementation.
> _"This is when you finally understand why a URL starts with HTTP"_
## โจ Features
- **Fully compliant with HTTP/1.1** protocol specifications
- **Non-blocking I/O operations** using poll/select/epoll/kqueue
- **Multiple virtual servers** support with different configurations
- **Method support**: GET, POST, DELETE
- **Static file serving** with directory listings
- **CGI support** for dynamic content
- **File uploads** handling
- **Error pages** customization
- **Redirections** configuration
- **Client body size limit** configuration
## ๐งฐ Requirements
- C++ compiler with C++98 support
- Make build system
- UNIX/Linux environment (or MacOS)
- No external libraries (standard library only)
## ๐๏ธ Project Structure
```
webserv/
โโโ src/
โ โโโ config/ # Configuration parsing
โ โโโ http/ # HTTP protocol handling
โ โโโ socket/ # Socket operations
โ โโโ server/ # Main server implementation
โ โโโ cgi/ # CGI implementation
โ โโโ utils/ # Utility functions and classes
โ โโโ main.cpp # Entry point
โโโ include/ # Header files
โโโ conf/ # Configuration examples
โโโ www/ # Web content examples
โโโ tests/ # Test scripts and files
โโโ Makefile # Build script
โโโ README.md # This file
```
## ๐ Building and Running
```bash
# Clone the repository
git clone https://github.com/jos-felipe/webserv.git
cd webserv
# Build the project
make
# Run with default configuration
./webserv
# Run with custom configuration
./webserv conf/custom.conf
```
## โ๏ธ Configuration File
The server uses a configuration file inspired by NGINX to set up different server instances and routes. Here's a basic example:
```
# Simple server configuration
server {
listen 8080;
server_name example.com;
root /var/www/html;
# Default error pages
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
# Client body size limit (in bytes)
client_max_body_size 10M;
# Route configuration
location / {
# Accepted HTTP methods
method GET POST;
# Directory listing
autoindex on;
# Default file for directories
index index.html;
}
# CGI configuration
location ~ \.php$ {
method GET POST;
cgi_pass /usr/bin/php-cgi;
}
# Redirection example
location /old {
return 301 /new;
}
# Upload configuration
location /upload {
method POST;
upload_store /tmp/uploads;
}
}
```
## ๐ Development Progress
- [x] Project setup and repository initialization
- [x] Configuration file parsing
- [x] Socket management and non-blocking I/O
- [x] HTTP request parsing
- [x] HTTP response generation
- [x] Static file serving
- [x] Directory listing
- [x] Error handling
- [x] CGI implementation
- [x] File upload handling
- [x] Testing and documentation
## ๐งช Testing
The server can be tested using:
- Web browsers (Chrome, Firefox, Safari, etc.)
- Command-line tools (curl, wget)
- Testing scripts (Python, Bash)
- Telnet for raw HTTP request testing
- External tools like Apache Bench for stress testing
## ๐ฅ Contributors
- [jos-felipe](https://github.com/jos-felipe)
- [Adedayo-Sanni](https://github.com/Adedayo-Sanni)
- [Thiagosdcavalcante](https://github.com/Thiagosdcavalcante)
## ๐ License
This project is part of the School 42 curriculum.