{"id":22383810,"url":"https://github.com/jorbush/http_server","last_synced_at":"2025-03-26T20:17:37.565Z","repository":{"id":248243562,"uuid":"828170687","full_name":"jorbush/http_server","owner":"jorbush","description":"an HTTP server written in Rust","archived":false,"fork":false,"pushed_at":"2024-07-13T12:10:18.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T02:16:32.002Z","etag":null,"topics":["http-server","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/jorbush.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-07-13T10:27:01.000Z","updated_at":"2024-07-13T12:10:21.000Z","dependencies_parsed_at":"2024-07-13T11:56:21.623Z","dependency_job_id":null,"html_url":"https://github.com/jorbush/http_server","commit_stats":null,"previous_names":["jorbush/http_server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorbush%2Fhttp_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorbush%2Fhttp_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorbush%2Fhttp_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorbush%2Fhttp_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jorbush","download_url":"https://codeload.github.com/jorbush/http_server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245727720,"owners_count":20662557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["http-server","rust"],"created_at":"2024-12-05T01:15:24.456Z","updated_at":"2025-03-26T20:17:37.539Z","avatar_url":"https://github.com/jorbush.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTP Server\n\nThis is a simple HTTP server written in Rust.\n\n## Requirements\n\n- Rust\n\n## Run the server\n\nTo run the server, you can use the following command:\n\n```bash\ncargo run -- --directory /tmp\n```\n\nIn other terminal, you can use the following command to test the server:\n\n```bash\ncurl -v http://localhost:4221\n```\n\n## Testing\n\nWith the server running, you can run the tests with the following command:\n```bash\ncargo test\n```\n\n## Lint\n\n```bash\ncargo fmt\n```\n\n## Features\n\n### Respond with 200 OK\n\n```bash\ncurl -v http://localhost:4221\n```\n\n```\nHTTP/1.1 200 OK\\r\\n\\r\\n\n```\n\n### Respond with 404 Not Found when the path is not defined\n\n```bash\ncurl -v http://localhost:4221/abcdefg\n```\n\n```\nHTTP/1.1 404 Not Found\\r\\n\\r\\n\n```\n\n### Respond with body\n\n```bash\ncurl -v http://localhost:4221/echo/abc\n```\n\n```\nHTTP/1.1 200 OK\\r\\nContent-Type: text/plain\\r\\nContent-Length: 3\\r\\n\\r\\nabc\n```\n\n### Read header\n\n```bash\ncurl -v --header \"User-Agent: foobar/1.2.3\" http://localhost:4221/user-agent\n```\n\n```\nHTTP/1.1 200 OK\\r\\nContent-Type: text/plain\\r\\nContent-Length: 12\\r\\n\\r\\nfoobar/1.2.3\n```\n\n### Concurrent connections\n\n```bash\n$ (sleep 3 \u0026\u0026 printf \"GET / HTTP/1.1\\r\\n\\r\\n\") | nc localhost 4221 \u0026\n$ (sleep 3 \u0026\u0026 printf \"GET / HTTP/1.1\\r\\n\\r\\n\") | nc localhost 4221 \u0026\n$ (sleep 3 \u0026\u0026 printf \"GET / HTTP/1.1\\r\\n\\r\\n\") | nc localhost 4221 \u0026\n```\n\n```\nHTTP/1.1 200 OK\\r\\n\\r\\n\nHTTP/1.1 200 OK\\r\\n\\r\\n\nHTTP/1.1 200 OK\\r\\n\\r\\n\n```\n\n### Return a file\n\n#### File found\n\n```bash\necho -n 'Hello, World!' \u003e /tmp/foo\ncurl -i http://localhost:4221/files/foo\n```\n\n```\nHTTP/1.1 200 OK\\r\\nContent-Type: application/octet-stream\\r\\nContent-Length: 13\\r\\n\\r\\nHello, World!\n```\n\n#### File not found\n\n```bash\ncurl -i http://localhost:4221/files/non_existant_file\n```\n\n```\nHTTP/1.1 404 Not Found\\r\\n\\r\\n\n```\n\n### Read request body\n\n```bash\ncurl -v --data \"12345\" -H \"Content-Type: application/octet-stream\" http://localhost:4221/files/file_123\n```\n\n```\nHTTP/1.1 201 Created\\r\\n\\r\\n\n```\n\n### Compression headers\n\n#### Valid Accept-Encoding header\n\n```bash\ncurl -v -H \"Accept-Encoding: gzip\" http://localhost:4221/echo/abc\n```\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/plain\nContent-Encoding: gzip\n...\n```\n\n#### Invalid Accept-Encoding header\n\n```bash\ncurl -v -H \"Accept-Encoding: invalid-encoding\" http://localhost:4221/echo/abc\n```\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/plain\n\n// Body omitted.\n```\n\n### Multiple compression schemes\n\n#### Contains one valid encoding\n\n```bash\ncurl -v -H \"Accept-Encoding: invalid-encoding-1, gzip, invalid-encoding-2\" http://localhost:4221/echo/abc\n```\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/plain\nContent-Encoding: gzip\n\n// Body omitted.\n```\n\n#### Contains all invalid encodings\n\n```bash\ncurl -v -H \"Accept-Encoding: invalid-encoding-1, invalid-encoding-2\" http://localhost:4221/echo/abc\n```\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/plain\n\n// Body omitted.\n```\n\n### Gzip compression\n\n```bash\ncurl -v -H \"Accept-Encoding: gzip\" http://localhost:4221/echo/abc | hexdump -C\n```\n\n```\nHTTP/1.1 200 OK\nContent-Encoding: gzip\nContent-Type: text/plain\nContent-Length: 23\n\n1F 8B 08 00 00 00 00 00\n00 03 4B 4C 4A 06 00 C2\n41 24 35 03 00 00 00\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorbush%2Fhttp_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorbush%2Fhttp_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorbush%2Fhttp_server/lists"}