Introduction

Webserv is one the milestones of the 42 cursus, it is the first project that approach socket programming. The project has to be HTTP/1.1 compliant and the goal is to have a program that behave almost like Nginx at the end. At first the project is really hard to apprehend and you have to go through a lot of documentation (which I recommend you to do), this document is an attempt to help 42 students, or anyone who is interested in programming his own HTTP server. Here you'll find a glimpse of the basic knowledge concerning socket, HTTP request, HTTP response, HTTP headers and CGI. I highly recommend you to make your own research to complement the information you'll find in this document (check the references section at the end).

This document was written by sgah and vdescham, students at the 42 Paris school in France. Find our githubs links at the end.


Prerequisite


The program

References :

RFC (HTTP/1.1): https://www.rfc-editor.org/rfc/rfc2616.html https://www.rfc-editor.org/rfc/rfc7230.html https://www.rfc-editor.org/rfc/rfc7231.html https://www.rfc-editor.org/rfc/rfc7232.html https://www.rfc-editor.org/rfc/rfc7233.html https://www.rfc-editor.org/rfc/rfc7234.html https://www.rfc-editor.org/rfc/rfc7235.html

Simple HTTP server from scratch : https://medium.com/from-the-scratch/http-server-what-do-you-need-to-know-to-build-a-simple-http-server-from-scratch-d1ef8945e4fa

Socket programming : https://www.geeksforgeeks.org/socket-programming-cc/ https://www.ibm.com/docs/en/zos/2.1.0?topic=calls-setsockopt https://man7.org/linux/man-pages/man3/setsockopt.3p.html https://stackoverflow.com/questions/14388706/how-do-so-reuseaddr-and-so-reuseport-differ

Select (FD_SET, FD_ISSET, etc) : https://man7.org/linux/man-pages/man2/select.2.html https://www.lowtek.com/sockets/select.html

Poll : https://www.ibm.com/docs/en/i/7.2?topic=designs-using-poll-instead-select ****http://www.mathcs.emory.edu/~cheung/Courses/455/Syllabus/9-netw-prog/timeout6.html

Epoll : https://linux.die.net/man/4/epoll ****http://manpagesfr.free.fr/man/man2/epoll_create.2.html ****https://man7.org/linux/man-pages/man2/epoll_ctl.2.html ****https://man7.org/linux/man-pages/man2/epoll_wait.2.html https://linux.die.net/man/2/epoll_wait