Skip to content

Yonaim/webserv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

736 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webserv

screenshot

webserv is an asynchronous HTTP/1.1 web server implemented in C++98, developed as part of the 42Seoul curriculum. The project benchmarks certain features and configuration styles of Nginx, but all core functionality is implemented from scratch. It covers socket programming, I/O multiplexing, HTTP request parsing, CGI handling, and more.


Features

  • Asynchronous I/O: Efficiently handles multiple client connections using kqueue.
  • HTTP/1.1 support: Implements core HTTP methods (GET, POST, DELETE) and full request parsing.
  • CGI support: Executes external programs to generate dynamic content, with environment variable setup and pipe management.
  • Config file parsing: Parses Nginx-style configuration files for flexible server behavior.
  • Cookie and session support: Supports state management using cookies and sessions.
  • Custom error pages and redirection: Allows custom error pages and URL redirection.

Project Structure

webserv/
├── config/             # Configuration files
├── cgi_bin/            # CGI scripts
├── data/               # Static resources
├── error/              # Error pages
├── source/             # Server source code
├── 42_tester/          # Test scripts and tools
├── Makefile            # Build script
├── leaks_check.sh      # Memory leak check script
├── spacex_test.sh      # Load test script
└── README.md           # Project documentation

Build & Run

1. Build

make

2. Run

./webserv [path_to_config]
  • If no config file is provided, the default configuration will be used.
  • Example configuration files can be found in the config/ directory.

Example Configuration

server {
    listen 8080;
    server_name localhost;
    root ./data;
    index index.html;

    location / {
        allow_methods GET POST DELETE;
        autoindex on;
    }

    location /cgi-bin/ {
        cgi_pass ./cgi_bin/script.py;
    }

    error_page 404 /error/404.html;
}

Testing & Benchmarking

  • Use the scripts in the 42_tester/ directory for automated testing.
  • For load testing, use spacex_test.sh.

Development Period

  • May 2023 – June 2023

References


Authors


License

Distributed under the MIT License. See the LICENSE file for details.

About

An asynchronous HTTP/1.1 web server written from scratch in C++98, featuring Nginx-style configuration and CGI support.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors