Code Monkey home page Code Monkey logo

webserv's Introduction

webserv

A simple non-blocking web server written in C++98 using Linux's epoll facility .

Usage

Pre-requisites

Linux > 2.5.44

g++ (or clang++) supporting C++98

Installation

git clone https://github.com/3lswear/webserv
cd webserv && make

Usage

webserv your_config_file.toml

Features

  • HTTP 1.1 compliant
    • Supported methods: GET, POST, DELETE, PUT
  • Non-blocking
  • Efficient resource usage (doesn't use CPU on idle)
  • Fair client handling (1 slow client won't slow down 50 fast clients)
  • Can listen on multiple ports/interfaces
  • TOML config format
    • multiple servers, with unique server_names
    • multiple location (route) blocks
      • location matching by path and wildcard
      • ability to limit allowed methods
    • redirections
    • toggleable directory listing support
    • set up custom error pages
    • set up a limit for a request body size

Collaborators

A team project made by:

Why ?

Why epoll?

Epoll is one of the modern event listeners/IO multiplexers out there (the other one is kqueue). Epoll works on the assumption that set manipulation is not as frequent as event handling, and the performance trade-offs are made accordingly. Although, it's not without its problems.

Why TOML for a config file?

TOML was our format of choice because it provides strict structure for a configuration, around which we could model our internal data structures. With a set file type like TOML the syntax is clear and unambiguous, and the tools like syntax highlighting and validation are already available. Also it isn't as hard to parse as YAML, although admittedly being less pretty. Lastly, we didn't just want to copy nginx's config structure.

Why make this project in the first place?

It was a great opportunity to learn writing bigger projects in C++, learn a little about network programming, how does OS handle network interaction, and to try tackling typical problems that come with socket IO and a need to serve a sizable amount of clients. Also, it was interesting to learn how software of similar purpose works (nginx uses epoll too!).

webserv's People

Contributors

3lswear avatar talyx avatar

Stargazers

 avatar

Watchers

 avatar

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.