Skip to content

stellaaash/webserv

Repository files navigation

This project has been created as part of the 42 curriculum by 0yech, stellaaa.sh.

webserv - A (Mostly HTTP 1.1) Web Server

Description

webserv is an HTTP web server capable of serving static websites, as well as calling CGI scripts.

It is entirely implemented in C++98, alongside several POSIX functions, including the Linux-exclusive epoll polling function. As such, this project is Linux-centric, and will likely not work on MacOS or Windows operating systems.

Key Features

  • Dynamic configuration based on configuration files
  • Listening on multiple ports at a time
  • Listening on multiple addresses at a time
  • I/O multiplexing using epoll
  • Connection timeouts
  • Static website distribution
  • CGI Script execution and results distribution (bring your own interpreter)
  • File uploads
  • Multiple HTTP methods: GET, POST and DELETE all available
  • HTTP redirection
  • Directory listings for easy browsing of resources

Instructions

Prerequisites

  • GNU Make
  • A Linux operating system with epoll support.

Usage

  1. Clone the repository on your machine
  2. Run make to compile the project. A webserv binary will be generated.
  3. Use ./webserv path/to/config/file to run your web server. Multiple configuration files examples are available in the config/ directory.
  4. You will then be able to access the web server through the ports and addresses defined in your configuration file. Use telnet, curl or a web browser to explore the resources and locations.

Use config/1.conf for an all-rounder configuration that will allow you to test several features of our web server.

For example, using the 1.conf example:

  • http://127.0.0.1:8080/: Gives you the webserv tester, a panel useful to try a few things out, including POST requests and CGI.
  • http://127.0.0.1:8080/images: Gives you a directory listing of the html/resources/images folder that you can explore freely.
  • http://127.0.0.1:8080/cgi-bin/script.py?key=value: Gives you an example of a Python CGI script running.

Resources

RFCs

  • RFC 1945 - The HTTP 1.0 standard, for the core functionality of HTTP, the how it works, not what it means (the semantics).
  • RFC 9112 - The HTTP 1.1 standard, for when we need to implement 1.1 specific features.
  • RFC 9110 - Provides a more recent covering of all HTTP semantics, and as such obsoletes a whole lot of older RFCs, including the 72XX ones. Think of it as the glossary of HTTP.
  • RFC 3875 - The Common Gateway Interface specification.
  • RFC 6265 - The RFC describing cookies.

Other Resources

AI Usage

AI (as in Large Language Models or LLMs) were used in both the design and implementation parts of this project. Its main utility was understanding concepts, and figuring out issues. Little to no actual code was written by an LLM, save for targeted refactors, such as moving/renaming functions, or changing a way a specific function was called after a signature change. LLMs were also used in the testing stage, in order to find still standing issues we hadn't found by ourselves. Issues found included chunked encoding and HTTP redirections issues.

About

An HTTP webserver!

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors