{"id":23864322,"url":"https://github.com/vrischmann/zig-picohttpparser","last_synced_at":"2026-02-22T22:13:30.087Z","repository":{"id":270781523,"uuid":"906808593","full_name":"vrischmann/zig-picohttpparser","owner":"vrischmann","description":"Small Zig wrapper for picohttpparser","archived":false,"fork":false,"pushed_at":"2025-04-29T16:42:11.000Z","size":19,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T01:04:29.348Z","etag":null,"topics":["http","picohttpparser","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/vrischmann.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-22T00:50:58.000Z","updated_at":"2025-04-29T18:29:09.000Z","dependencies_parsed_at":"2025-01-03T04:12:49.974Z","dependency_job_id":"7f7c6214-64e7-44d4-86de-c01c616d5ad2","html_url":"https://github.com/vrischmann/zig-picohttpparser","commit_stats":null,"previous_names":["vrischmann/zig-picohttpparser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vrischmann/zig-picohttpparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrischmann%2Fzig-picohttpparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrischmann%2Fzig-picohttpparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrischmann%2Fzig-picohttpparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrischmann%2Fzig-picohttpparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vrischmann","download_url":"https://codeload.github.com/vrischmann/zig-picohttpparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrischmann%2Fzig-picohttpparser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261783374,"owners_count":23208948,"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","picohttpparser","zig"],"created_at":"2025-01-03T08:20:48.265Z","updated_at":"2026-02-22T22:13:30.039Z","avatar_url":"https://github.com/vrischmann.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-picohttpparser\n\nThis is a small Zig wrapper to use [picohttpparser](https://github.com/h2o/picohttpparser).\n\n`picohttpparser` could be used directly but this wrapper makes it feel more idiomatic Zig.\n\nThis package leverages the Zig build system and is based on [zig-picohttpparser-sys](https://github.com/vrischmann/zig-picohttpparser-sys).\n\n# Supported Zig version\n\nOnly Zig master is currently supported. Once 0.14.0 is released we should be able to support it.\n\n# Installation\n\nUse `zig fetch`:\n\n```\nzig fetch --save git+https://github.com/vrischmann/zig-picohttpparser#master\n```\n\nYou can then import `picohttpparser` in your `build.zig`:\n```zig\nconst picohttpparser = b.dependency(\"picohttpparser\", .{\n    .target = target,\n    .optimize = optimize,\n});\n\nyour_exe.addImport(\"picohttpparser\", picohttpparser.module(\"picohttpparser\"));\n```\n\n# Features implemented\n\npicohttpparser doesn't have many features. The following is a list of what is implemented in this wrapper.\n\n* [x] Parsing a request\n* [ ] Parsing a response\n* [ ] Parsing chunk-encoded data\n* [ ] Parsing headers only\n\n# Usage\n\nThere is only one function exposed, `parseRequest`:\n```\npub fn parseRequest(buffer: []const u8, previous_buffer_len: usize) ParseRequestError!?ParseRequestResult {\n```\n\nThis function takes in a _buffer_ and a _previous buffer length_ and returns either a parsing error or a result.\n\nThe buffer is easy to understand, it's the string you want to parse as an HTTP request.\nThe previous buffer length is the length in the current buffer that you already tried to parse. This is needed to resume parsing incomplete buffers.\n\nThe returned result contains the raw request (of type `RawRequest`) and the number of bytes consumed from the buffer.\n\nHere is an example usage:\n```zig\nconst std = @import(\"std\");\nconst picohttpparser = @import(\"picohttpparser\");\n\npub fn main() !void {\n    const data = \"GET /lol/foo HTTP/1.0\\r\\nfoo: ab\\r\\nContent-Length: 200\\r\\n\\r\\n\";\n\n    if (try picohttpparser.parseRequest(data, 0)) |result| {\n        std.log.info(\"request: {s}, consumed: {d}\", .{ result.raw_request.getPath(), result.consumed });\n    }\n}\n```\n\nThis assumes the data is complete, in the real world you probably can't assume this. You probably want to do something like this:\n```zig\nvar buf = std.ArrayList(u8).init(allocator);\nconst result = while (true) {\n    // Feed more data to buf somehow: read from a socket, copy from another buffer, etc\n\n    if (try picohttpparser.parseRequest(buf.items, 0)) |result| {\n        break result;\n    }\n};\n\n// Use the result\n```\n\nLook into [example/main.zig](/example/main.zig) for a more complete example.\n\nYou can also take a look at my project [zig-io_uring-http-server](https://github.com/vrischmann/zig-io_uring-http-server) where I [use `picohttpparser`](https://github.com/vrischmann/zig-io_uring-http-server/blob/master/src/lib.zig#L841-L855).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrischmann%2Fzig-picohttpparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvrischmann%2Fzig-picohttpparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrischmann%2Fzig-picohttpparser/lists"}