{"id":29435917,"url":"https://github.com/xyurt/httplite","last_synced_at":"2025-07-19T17:02:04.081Z","repository":{"id":304412429,"uuid":"1018717617","full_name":"xyurt/httplite","owner":"xyurt","description":"httplite — A minimal, single header, zero-copy, zero-allocation HTTP/1.1 parser in C and compatible with C89. Uses only pointer arithmetic and nothing else in only 50 lines.","archived":false,"fork":false,"pushed_at":"2025-07-12T22:21:15.000Z","size":28,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-13T00:18:34.609Z","etag":null,"topics":["c","c89","fast","fastest","http","http1-1","https","library","microhttp","most","optimized","parse","parser","single-header","small","smallest","smallhttp","tiny","tinyhttp","zero-allocation"],"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/xyurt.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}},"created_at":"2025-07-12T22:02:35.000Z","updated_at":"2025-07-12T23:06:50.000Z","dependencies_parsed_at":"2025-07-13T00:18:51.404Z","dependency_job_id":"d259421c-1851-4e40-86ad-c21af9700ab5","html_url":"https://github.com/xyurt/httplite","commit_stats":null,"previous_names":["xyurt/httplite"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/xyurt/httplite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyurt%2Fhttplite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyurt%2Fhttplite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyurt%2Fhttplite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyurt%2Fhttplite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyurt","download_url":"https://codeload.github.com/xyurt/httplite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyurt%2Fhttplite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265244516,"owners_count":23733948,"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":["c","c89","fast","fastest","http","http1-1","https","library","microhttp","most","optimized","parse","parser","single-header","small","smallest","smallhttp","tiny","tinyhttp","zero-allocation"],"created_at":"2025-07-13T04:05:25.661Z","updated_at":"2025-07-14T05:02:46.871Z","avatar_url":"https://github.com/xyurt.png","language":"C","readme":"# httplite\n\nA minimal and single-header HTTP/1.1 request line and header parser written in pure C.\n\n## Overview\n\nhttplite is an ultra lightweight, zero-allocation HTTP/1.1 parser designed for blazing-fast parsing using only pointer arithmetic. It parses HTTP request or response lines and headers directly from the input buffer without copying data.\n\n## LOC\nThe header file is exactly 50 lines in total...\n\n## Usage Example \n\n```C\n#include \"httplite.h\"\n#include \u003cstdio.h\u003e\n\nvoid main() {\n    const char *request = \"GET /index.html HTTP/1.1\\r\\nHost: example.com\\r\\nConnection: close\\r\\n\\r\\n\"; /* A typical http request */\n    size_t len = 66; /* Length of request without the null terminator */\n\n    http_message message; /* Http message structure */\n    if (http_parse_message(request, len, \u0026message)) {\n        printf(\"Method: %.*s\\n\", (int)message.part1_length, message.part1);\n        printf(\"Path: %.*s\\n\", (int)message.part2_length, message.part2);\n        printf(\"Version: %.*s\\n\", (int)message.part3_length, message.part3);\n\n        const char *name, *value;\n        size_t name_len, value_len;\n\n        printf(\"Headers:\\n\");\n        while (http_next_header(\u0026message, \u0026name, \u0026name_len, \u0026value, \u0026value_len)) {\n            if (name == NULL || name_len == 0) break;\n            printf(\"  %.*s: %.*s\\n\", (int)name_len, name, (int)value_len, value);\n        }\n\n        if (message.next_length != 0) {\n            printf(\"Body:\\n%.*s\\n\", (int)message.next_length, message.next);\n        }\n    }\n    else {\n        printf(\"Failed to parse HTTP message\\n\");\n    }\n}\n```\n\n## How It Works\n\n- Parses HTTP/1.x request or response line (method, path, version).\n- Iterates over headers with zero-copy pointer arithmetic like a stream.\n- No dependencies, dynamic memory allocation or even the standart library.\n\n## API\n\n- int http_parse_message(const char *buffer, size_t buffer_size, http_message *out);\n  Parses the start line and initializes the message for header parsing.\n\n- int http_next_header(http_message *message, const char **name, size_t *name_length, const char **value, size_t *value_length);\n  Iterates headers one by one; returns 1 while headers remain, 0 at end or error.\n\n## Performance Notes\n- Zero-copy parsing ensures minimal CPU and memory overhead.\n- Suitable for high-throughput or embedded environments.\n\n## Limitations\n\n- Supports HTTP/1.x request line, response line and headers only.\n- Expects CRLF (\\r\\n) line endings.\n- Does not validate message bodies or headers, just does its primary job which is parsing.\n- No support for multiline headers or chunked encoding.\n\n## License\n\nMIT License\n\n---\n\nMinimal, blazing-fast HTTP/1.1 parsing using only pointer arithmetic for zero-copy efficiency.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyurt%2Fhttplite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyurt%2Fhttplite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyurt%2Fhttplite/lists"}