{"id":23773036,"url":"https://github.com/42mates/webserv","last_synced_at":"2026-05-14T21:04:43.025Z","repository":{"id":270349023,"uuid":"910073210","full_name":"42mates/webserv","owner":"42mates","description":"Repo for the webserv project from 42 school by @marinsucks and @Soner-K. ","archived":false,"fork":false,"pushed_at":"2025-04-02T14:46:05.000Z","size":6089,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-02T06:34:59.455Z","etag":null,"topics":["cpp98","nginx","webserver"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/42mates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2024-12-30T12:30:07.000Z","updated_at":"2025-05-20T12:30:26.000Z","dependencies_parsed_at":"2025-01-15T17:01:31.422Z","dependency_job_id":"829ad607-318f-4795-bafd-a1fd473583a8","html_url":"https://github.com/42mates/webserv","commit_stats":null,"previous_names":["42mates/webserv"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/42mates/webserv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42mates%2Fwebserv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42mates%2Fwebserv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42mates%2Fwebserv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42mates%2Fwebserv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/42mates","download_url":"https://codeload.github.com/42mates/webserv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42mates%2Fwebserv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33043251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cpp98","nginx","webserver"],"created_at":"2025-01-01T05:22:36.525Z","updated_at":"2026-05-14T21:04:43.004Z","avatar_url":"https://github.com/42mates.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Webserv\n\nWebserv is a lightweight HTTP server implemented in C++ as part of the 42 school curriculum. It supports multiple features such as configuration file parsing, non-blocking socket operations, CGI script handling, and robust request/response management.\n\n---\n\n## Features\n\n### 1. Configuration File Management\n- The server is configured using a custom configuration file (`webserv.conf`), which allows defining:\n  - Server blocks with specific settings (e.g., `root`, `methods`, `index_file`, etc.).\n  - Route-specific configurations like `upload_dir`, `cgi_path`, and `http_redirect`.\n  - HTTP methods allowed (`GET`, `POST`, `DELETE`, etc.).\n- The configuration file is parsed into structured objects (`ServerConfig`, `RouteConfig`) for easy access during runtime.\n- Errors in the configuration file (e.g., unknown directives, invalid arguments) are detected and reported.\n\n### 2. Non-Blocking Sockets and Event Monitoring\n- Webserv uses non-blocking sockets to handle multiple connections simultaneously.\n- The `poll()` system call is used to monitor events on listening sockets and client connections.\n- Based on the events (e.g., `POLLIN`, `POLLOUT`), the server performs actions such as:\n  - Accepting new connections.\n  - Reading incoming requests.\n  - Sending responses to clients.\n- This architecture ensures high performance and scalability.\n\n### 3. Request Parsing and Response Handling\n- The server parses incoming HTTP requests, including:\n  - Start line (method, URI, version).\n  - Headers (e.g., `Host`, `Content-Type`).\n  - Body (supports `chunked` and `multipart` encoding).\n- Responses are generated with appropriate status codes (`200 OK`, `404 Not Found`, `500 Internal Server Error`, etc.).\n- Error handling is robust, with detailed error messages for invalid requests or server-side issues.\n\n### 4. CGI Script Management\n- Webserv supports executing CGI scripts in python for dynamic content generation.\n- CGI execution is managed with:\n  - Environment variable initialization.\n  - Timeout handling to prevent hanging scripts.\n  - Proper error handling for script failures or invalid outputs.\n- The server ensures that CGI scripts do not block other operations.\n### 5. Stress-Tested Non-Blocking Mode\n- Webserv operates in non-blocking mode, ensuring high availability and responsiveness under heavy load.\n- The server successfully passed a stress test using `siege`:\n\t```\n\tLifting the server siege...\n\tTransactions:                 121815 hits\n\tAvailability:                 100.00 %\n\tElapsed time:                  59.40 secs\n\tData transferred:             182.51 MB\n\tResponse time:                  0.00 secs\n\tTransaction rate:            2050.76 trans/sec\n\tThroughput:                     3.07 MB/sec\n\tConcurrency:                    1.46\n\tSuccessful transactions:      121815\n\tFailed transactions:               0\n\tLongest transaction:            1.04\n\tShortest transaction:           0.00\n\t```\n- This stress test can be replicated using the command:\n\t```bash\n\tmake siege\n\t```\n\tNote: Ensure `siege` is installed as a dependency before running the test.\n\n---\n\n## How to Run\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/your-repo/webserv.git\n   cd webserv\n   ```\n\n2. Build the project:\n   ```bash\n   make\n   ```\n\n3. Run the server:\n   ```bash\n   ./webserv [config_file]\n   ```\n   If no configuration file is provided, the default `tools/config/webserv.conf` is used.\n\n---\n\n## Directory Structure\n- **`src/`**: Contains the source code for the server, including request/response handling, configuration parsing, and CGI management.\n- **`tools/website/`**: Static and dynamic content for testing the server.\n- **`tools/config/`**: Default configuration file (`webserv.conf`).\n\n---\n\n## Authors\n- [@marinsucks](https://github.com/marinsucks)\n- [@sokaraku](https://github.com/sokaraku)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F42mates%2Fwebserv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F42mates%2Fwebserv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F42mates%2Fwebserv/lists"}