{"id":15064668,"url":"https://github.com/f321x/webserv-42-core","last_synced_at":"2026-03-07T20:32:02.023Z","repository":{"id":255498687,"uuid":"851568879","full_name":"f321x/webserv-42-core","owner":"f321x","description":"Implementation of a HTTP1.1 and nginx config compatible webserver in C++ 17. 42 core curriculum project.","archived":false,"fork":false,"pushed_at":"2024-11-14T16:08:05.000Z","size":11767,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T13:04:13.088Z","etag":null,"topics":["42","42born2code","42commoncore","42school","http","nginx","sockets","unix","webserver"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/f321x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-03T10:35:03.000Z","updated_at":"2025-01-16T17:17:52.000Z","dependencies_parsed_at":"2024-10-13T00:21:43.080Z","dependency_job_id":"4efce329-e3ec-4e9a-86b4-2b224564fb11","html_url":"https://github.com/f321x/webserv-42-core","commit_stats":null,"previous_names":["f321x/webserv-42-core"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/f321x/webserv-42-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f321x%2Fwebserv-42-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f321x%2Fwebserv-42-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f321x%2Fwebserv-42-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f321x%2Fwebserv-42-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f321x","download_url":"https://codeload.github.com/f321x/webserv-42-core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f321x%2Fwebserv-42-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30229744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42born2code","42commoncore","42school","http","nginx","sockets","unix","webserver"],"created_at":"2024-09-25T00:24:06.029Z","updated_at":"2026-03-07T20:32:02.002Z","avatar_url":"https://github.com/f321x.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Webserv\n\n## This is when you finally understand why a URL starts with HTTP\n\n```\nSummary:\nThis project is about writing your own HTTP server.\nYou will be able to test it with an actual browser.\nHTTP is one of the most used protocols on the internet.\nKnowing its arcane will be useful, even if you won’t be working on a website.\n```\n\n## Contents\n\n1. Introduction\n2. General rules\n3. Mandatory part\n   - 1. Requirements\n   - 2. For MacOS only\n   - 3. Configuration file\n4. Bonus part\n5. Submission and peer-evaluation\n\n\n# Chapter I\n\n# Introduction\n\nThe **Hypertext Transfer Protocol** (HTTP) is an application protocol for distributed,\ncollaborative, hypermedia information systems.\n\nHTTP is the foundation of data communication for the World Wide Web, where hy-\npertext documents include hyperlinks to other resources that the user can easily access.\nFor example, by a mouse click or by tapping the screen in a web browser.\n\n```\nHTTP was developed to facilitate hypertext and the World Wide Web.\n```\nThe primary function of a web server is to store, process, and deliver web pages to\nclients. The communication between client and server takes place using the Hypertext\nTransfer Protocol (HTTP).\n\nPages delivered are most frequently HTML documents, which may include images,\nstyle sheets, and scripts in addition to the text content.\n\n```\nMultiple web servers may be used for a high-traffic website.\n```\nA user agent, commonly a web browser or web crawler, initiates communication by\nrequesting a specific resource using HTTP and the server responds with the content of\nthat resource or an error message if unable to do so. The resource is typically a real file\non the server’s secondary storage, but this is not necessarily the case and depends on how\nthe webserver is implemented.\n\nWhile the primary function is to serve content, full implementation of HTTP also\nincludes ways of receiving content from clients. This feature is used for submitting web\nforms, including the uploading of files.\n\n\n# Chapter II\n\n# General rules\n\n- Your program should not crash in any circumstances (even when it runs out of\n    memory), and should not quit unexpectedly.\n    If it happens, your project will be considered non-functional and your grade will be\n    0.\n- You have to turn in aMakefilewhich will compile your source files. It must not\n    relink.\n- YourMakefilemust at least contain the rules:\n    $(NAME),all,clean,fcleanandre.\n- Compile your code withc++and the flags-Wall -Wextra -Werror\n- Your code must comply with the **C++ 98 standard**. Then, it should still compile\n    if you add the flag-std=c++98.\n- Try to always develop using the mostC++features you can (for example, choose\n    \u003ccstring\u003eover\u003cstring.h\u003e). You are allowed to useCfunctions, but always prefer\n    theirC++versions if possible.\n- Any external library andBoostlibraries are forbidden.\n\n\n# Chapter III\n\n# Mandatory part\n\n```\nProgram name webserv\nTurn in files Makefile, *.{h, hpp}, *.cpp, *.tpp, *.ipp,\nconfiguration files\nMakefile NAME, all, clean, fclean, re\nArguments [A configuration file]\nExternal functs. Everything in C++ 98.\nexecve, dup, dup2, pipe, strerror, gai_strerror,\nerrno, dup, dup2, fork, socketpair, htons, htonl,\nntohs, ntohl, select, poll, epoll (epoll_create,\nepoll_ctl, epoll_wait), kqueue (kqueue, kevent),\nsocket, accept, listen, send, recv, chdir bind,\nconnect, getaddrinfo, freeaddrinfo, setsockopt,\ngetsockname, getprotobyname, fcntl, close, read,\nwrite, waitpid, kill, signal, access, stat, open,\nopendir, readdir and closedir.\nLibft authorized n/a\nDescription A HTTP server in C++ 98\n```\n```\nYou must write a HTTP server in C++ 98.\n```\n```\nYour executable will be run as follows:\n```\n```\n./webserv [configuration file]\n```\n```\nEven if poll() is mentionned in the subject and the evaluation scale,\nyou can use any equivalent such as select(), kqueue(), or epoll().\n```\n\nWebserv This is when you finally understand why a URL starts with HTTP\n\n```\nPlease read the RFC and do some tests with telnet and NGINX before\nstarting this project.\nEven if you don’t have to implement all the RFC, reading it will help\nyou develop the required features.\n```\n\nWebserv This is when you finally understand why a URL starts with HTTP\n\n### a. Requirements\n\n- Your program has to take a configuration file as argument, or use a default path.\n- You can’texecveanother web server.\n- Your server must never block and the client can be bounced properly if necessary.\n- It must be non-blocking and use only **1** poll() (or equivalent) for all the I/O\n    operations between the client and the server (listen included).\n- poll()(or equivalent) must check read and write at the same time.\n- You must never do a read or a write operation without going throughpoll()(or\n    equivalent).\n- Checking the value oferrnois strictly forbidden after a read or a write operation.\n- You don’t need to usepoll()(or equivalent) before reading your configuration file.\n\n```\nBecause you have to use non-blocking file descriptors, it is\npossible to use read/recv or write/send functions with no poll()\n(or equivalent), and your server wouldn’t be blocking.\nBut it would consume more system resources.\nThus, if you try to read/recv or write/send in any file descriptor\nwithout using poll() (or equivalent), your grade will be 0.\n```\n- You can use every macro and define likeFD_SET,FD_CLR,FD_ISSET,FD_ZERO(un-\n    derstanding what and how they do it is very useful).\n- A request to your server should never hang forever.\n- Your server must be compatible with the **web browser** of your choice.\n- We will consider that NGINX is HTTP 1.1 compliant and may be used to compare\n    headers and answer behaviors.\n- Your HTTP response status codes must be accurate.\n- You server must have **default error pages** if none are provided.\n- You can’t use fork for something else than CGI (like PHP, or Python, and so forth).\n- You must be able to **serve a fully static website**.\n- Clients must be able to **upload files**.\n- You need at leastGET,POST, andDELETEmethods.\n- Stress tests your server. It must stay available at all cost.\n- Your server must be able to listen to multiple ports (see _Configuration file_ ).\n\n\nWebserv This is when you finally understand why a URL starts with HTTP\n\n### b. For MacOS only\n\n```\nSince MacOS doesn’t implement write() the same way as other Unix\nOSes, you are allowed to use fcntl().\nYou must use file descriptors in non-blocking mode in order to get a\nbehavior similar to the one of other Unix OSes.\n```\n```\nHowever, you are only allowed to use fcntl() with the following\nflags:\nF_SETFL, O_NONBLOCK and FD_CLOEXEC.\nAny other flag is forbidden.\n```\n### c. Configuration file\n\n```\nYou can get some inspiration from the ’server’ part of NGINX\nconfiguration file.\n```\n```\nIn the configuration file, you should be able to:\n```\n- Choose the port and host of each ’server’.\n- Setup theserver_namesor not.\n- The first server for ahost:portwill be the default for thishost:port(that means\n    it will answer to all the requests that don’t belong to an other server).\n- Setup default error pages.\n- Limit client body size.\n- Setup routes with one or multiple of the following rules/configuration (routes wont\n    be using regexp):\n\n```\n◦ Define a list of accepted HTTP methods for the route.\n◦ Define a HTTP redirection.\n```\n```\n◦ Define a directory or a file from where the file should be searched (for example,\nif url/kapouet is rooted to/tmp/www, url /kapouet/pouic/toto/pouetis\n/tmp/www/pouic/toto/pouet).\n```\n```\n◦ Turn on or off directory listing.\n```\n\nWebserv This is when you finally understand why a URL starts with HTTP\n\n```\n◦ Set a default file to answer if the request is a directory.\n```\n```\n◦ Execute CGI based on certain file extension (for example .php).\n```\n```\n◦ Make it work with POST and GET methods.\n```\n```\n◦ Make the route able to accept uploaded files and configure where they should\nbe saved.\n∗ Do you wonder what a CGI is?\n∗ Because you won’t call the CGI directly, use the full path asPATH_INFO.\n∗ Just remember that, for chunked request, your server needs to unchunk\nit, the CGI will expectEOFas end of the body.\n∗ Same things for the output of the CGI. If nocontent_lengthis returned\nfrom the CGI,EOFwill mark the end of the returned data.\n∗ Your program should call the CGI with the file requested as first argument.\n∗ The CGI should be run in the correct directory for relative path file access.\n∗ Your server should work with one CGI (php-CGI, Python, and so forth).\n```\nYou must provide some configuration files and default basic files to test and demon-\nstrate every feature works during evaluation.\n\n```\nIf you’ve got a question about one behavior, you should compare your\nprogram behavior with NGINX’s.\nFor example, check how does server_name work.\nWe’ve shared with you a small tester. It’s not mandatory to pass it\nif everything works fine with your browser and tests, but it can help\nyou hunt some bugs.\n```\n```\nThe important thing is resilience. Your server should never die.\n```\n```\nDo not test with only one program. Write your tests with a more\nconvenient language such as Python or Golang, and so forth. Even in\nC or C++ if you want to.\n```\n\n# Chapter IV\n\n# Bonus part\n\nHere are the extra features you can add:\n\n- Support cookies and session management (prepare quick examples).\n- Handle multiple CGI.\n\n```\nThe bonus part will only be assessed if the mandatory part is\nPERFECT. Perfect means the mandatory part has been integrally done\nand works without malfunctioning. If you have not passed ALL the\nmandatory requirements, your bonus part will not be evaluated at all.\n```\n\n# Chapter V\n\n# Submission and peer-evaluation\n\nTurn in your assignment in your Gitrepository as usual. Only the work inside your\nrepository will be evaluated during the defense. Don’t hesitate to double check the\nnames of your files to ensure they are correct.\n\n```\n16D85ACC441674FBA2DF65190663F42A3832CEA21E024516795E1223BBA77916734D\n26120A16827E1B16612137E59ECD492E46EAB67D109B142D49054A7C281404901890F\n619D682524F\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff321x%2Fwebserv-42-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff321x%2Fwebserv-42-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff321x%2Fwebserv-42-core/lists"}