{"id":50668343,"url":"https://github.com/humankernel/http-server","last_synced_at":"2026-06-08T08:09:16.935Z","repository":{"id":290471470,"uuid":"974567065","full_name":"humankernel/http-server","owner":"humankernel","description":"HTTP Server from Scratch ","archived":false,"fork":false,"pushed_at":"2025-11-03T23:46:47.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-04T01:19:24.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/humankernel.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-29T01:24:13.000Z","updated_at":"2025-11-03T23:46:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"96161040-d89d-4c1a-af3d-c83b7f45155a","html_url":"https://github.com/humankernel/http-server","commit_stats":null,"previous_names":["humankernel/http-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/humankernel/http-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humankernel%2Fhttp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humankernel%2Fhttp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humankernel%2Fhttp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humankernel%2Fhttp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humankernel","download_url":"https://codeload.github.com/humankernel/http-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humankernel%2Fhttp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34053649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"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":[],"created_at":"2026-06-08T08:07:44.294Z","updated_at":"2026-06-08T08:09:16.924Z","avatar_url":"https://github.com/humankernel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚙️ Simple HTTP Server from Scratch (Go)\n\nA minimal yet fully functional **HTTP/1.1 server built from scratch in Go**, without using `net/http` for handling requests or responses.\nThis project was inspired by the [Codecrafters HTTP Server Challenge](https://app.codecrafters.io/courses/http-server) and rebuilt from the ground up to deepen understanding of low-level networking and the HTTP protocol.\n\n## 🚀 Features\n\n✅ **Manual TCP Handling** — Uses Go’s `net` package directly (`net.Listen`, `net.Conn`) to accept and manage client connections.\n\n✅ **HTTP/1.1 Parsing** — Parses request lines, headers, and bodies manually via buffered I/O.\n\n✅ **Persistent Connections** — Supports `Connection: keep-alive` and `Connection: close`.\n\n✅ **Custom Routing** — Handles multiple routes without using frameworks:\n\n* `/` — Simple health check.\n* `/echo/\u003ctext\u003e` — Responds with the given text.\n* `/user-agent` — Returns the client’s `User-Agent` header.\n* `/files/\u003cfilename\u003e` —\n  • `GET`: Serves static files from a provided directory.\n  • `POST`: Writes file contents to disk.\n\n✅ **Gzip Compression** — Compresses responses when the client includes `Accept-Encoding: gzip`.\n\n✅ **File I/O Handling** — Secure path resolution and support for reading/writing binary files.\n\n✅ **Proper Status Codes** — Returns `200 OK`, `201 Created`, `404 Not Found`, `500 Internal Server Error`, etc.\n\n✅ **Concurrent Connections** — Handles multiple clients via goroutines.\n\n✅ **Verbose Logging** — Logs request lifecycle and connection details.\n\n## 🧩 Getting Started\n\n### 1. Clone the repo\n\n```bash\ngit clone https://github.com/humankernel/http-server.git\ncd http-server\n```\n\n### 2. Run the server\n\nYou must provide a file directory path for `/files` route:\n\n```bash\ngo run app/main.go ./tmp\n```\n\n### 3. Try some requests\n\n```bash\n# Echo\ncurl -v http://localhost:4221/echo/hello\n\n# User-Agent\ncurl -v http://localhost:4221/user-agent\n\n# Upload a file\ncurl -v -X POST --data-binary @example.txt http://localhost:4221/files/example.txt\n\n# Download a file\ncurl -v http://localhost:4221/files/example.txt\n```\n\n### 4. Observe raw traffic (optional)\n\n```bash\nsudo tcpdump -i any -n host localhost\n```\n\n---\n\n### 📂 Example Response\n\n```\n\u003e GET /echo/hi HTTP/1.1\n\u003e Host: localhost:4221\n\n\u003c HTTP/1.1 200 OK\n\u003c Content-Type: text/plain\n\u003c Content-Length: 2\n\nhi\n```\n\n## 🧭 Project Structure\n\n```\nhttp-server/\n├── app/\n│   └── main.go        # Core server implementation\n├── tmp/               # Example directory for /files route\n└── README.md\n```\n\n## 💡 Future Improvements\n\n* Add proper routing abstraction (similar to `http.ServeMux`)\n* Implement chunked transfer encoding and streaming responses\n* Improve security and header handling","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumankernel%2Fhttp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumankernel%2Fhttp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumankernel%2Fhttp-server/lists"}