GithubHelp home page GithubHelp logo

0bvim / webserv Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 2.0 1.62 MB

This is when you finally understand why a URL starts with HTTP

License: MIT License

Makefile 2.57% C++ 85.76% HTML 8.97% Dockerfile 0.70% CMake 1.93% Python 0.07%

webserv's Introduction

webserv

This is when you finally understand why a URL starts with HTTP

webserv's People

Contributors

0bvim avatar lumedeir avatar brmoretti avatar

Stargazers

Daniel Bruno avatar Eric Ung avatar  avatar ab25cq avatar

Watchers

 avatar

webserv's Issues

Configuration

Start

  • Config.cpp and header
  • Parse and Store configuration options
  • Validate configuration
  • Log Configuration Errors
  • Fallback to default Settings

Client

Client Implementation

  • Client.cpp and Client.hpp
  • Define Client Class
  • Manage client state
  • Track Client's connection status
  • buffer client data
  • send and receive Data

Server

Start

  • Create server cpp and header file
  • define server class

Implement CPP file

  • constructor in canonical form
  • init server variables
    • Port, Host, Routes

Sockets

  • Create Non-blocking Socket and Bind (use SOCK_NONBLOCK macro)
  • Handle Socket Errors
  • Throw Exception on Error

Event

  • Set up Event Loop
  • Use poll or equivalent
  • Handle incoming connections
  • Accept new clients connections
  • Manage client connections in Event Loop

Handle HTTP requests

  • Parse HTTP headers
  • Determine Request Type:
    • GET
      • Server Static Content
      • Locate Requested File
      • Send File to Client
      • Handle 404 Errors
    • POST
      • Handle Form Submissions
      • Parse Form Data
      • Save uploaded Files
      • Send Response to Client
    • DELETE
      • Delete resources
      • Verify Resources existence
      • Remove resource
      • Send confirmation to client

Implement CGI Handlign

  • Detect CGI request based on Extension
  • Execute CGI Script with execve
  • Pass Environment variables to CGI
  • Capture CGI Output
  • Send CGI responde to client

Main file

  • Initializer server setup
  • parse configuration file
    • load configuration parameter
    • set default config file if not provided

Use one poll() or equivalent

consider poll() to equivalent that we are using (epoll())

  • poll() must check read and write at the same time
  • never do a read or a write operation without going through poll()
  • checking the value of errno is forbidden after a read or a write operation.
  • don't use poll() before reading your configuration file

Testing and debugging

Testing

  • Write Unit Tests with google test suite
  • Test Server Response Codes
  • Test Static file Serving
  • Tests CGI Execution

Debugging

  • Stress Test Server
  • Simulate Multiple Clients Connections
  • Verify server stability

Tests

updated tests to still working with new implementation

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.