/42_Webserv

A mini web server with C++

Primary LanguageC++MIT LicenseMIT

Webserv

A mini web server with C++

HTTP 1.1 standard

RFCs

HTTP/1.1 (RFC 2616)
HTTP/1.1 : Message Syntax and Routing (RFC 7230)
HTTP/1.1 : Semantics and Content (RFC 7231)
HTTP/1.1 : Conditional Requests (RFC 7232)
HTTP/1.1 : Range Requests (RFC 7233)
HTTP/1.1 : Caching (RFC 7234)
HTTP/1.1 : Authentication (RFC 7235)
HTTP Semantics (RFC 9110)

other docs

mdn web docs - HTTP resources and specifications
Wikipedia - Hypertext Transfer Protocol
HTTP Server: Everything you need to know to Build a simple HTTP server from scratch

configuration file

src/config

request and response handling

socket(), bind(), listen()

srcs/socket

epoll(), accept(), connect(), recv(), send()

srcs/server

I/O multiplexing

differences among select(), kqueue(), poll(), epoll()

  • Synchronous
    select and poll

  • Asynchronous
    epoll and kqueue

  • epoll is supported on Linux system

  • kqueue is supported on BSD/MacOS system

Handling the request

srcs/client

POST request and multipart/form-data

Create the response

srcs/response

CGI

Testing

stress test with siege

./Desktop/siege/bin/siege -t 20S -c 10 -v 127.0.0.1:8080/index.html

telnet

telnet 127.0.0.1 8080

GET /index.html HTTP/1.1
Host: 127.0.0.1

GET /get_php.php HTTP/1.1
Host: 127.0.0.1

curl with hostname

curl --resolve example.com:8080:127.0.0.1 http://example.com:8080/

https://www.onlinenotepad.io/