HTTP request/response parser extracted from nodejs/llhttp.
This is the HTTP parser used by Node.js - battle-tested against billions of requests. It's a pure C library with no dependencies, designed for high-performance HTTP parsing with a callback-based, zero-copy API.
- Upstream Repository: https://github.com/nodejs/llhttp
- Upstream Version: v9.3.0
- Upstream Commit: release/v9.3.0
- Upstream Date: 2025年05月23日
- License: MIT - see LICENSE
- Pure C, zero dependencies
- Callback-based, zero-copy parsing (pointers into your buffer)
- Incremental parsing (feed bytes as they arrive)
- Handles all HTTP/1.x edge cases:
- Chunked transfer encoding
- Keep-alive detection
- Header line folding
- Request pipelining
- Content-Length vs Transfer-Encoding
- ~20KB compiled
- Extensively tested (Node.js test suite)
-
Check for new releases at https://github.com/nodejs/llhttp/releases
-
Download the release tarball:
gh release download release/vX.Y.Z --repo nodejs/llhttp --archive=tar.gz -D /tmp cd /tmp && tar -xzf nodejs-llhttp-*.tar.gz
-
Copy the files:
cp /tmp/llhttp-release-vX.Y.Z/include/llhttp.h include/ cp /tmp/llhttp-release-vX.Y.Z/src/*.c src/ cp /tmp/llhttp-release-vX.Y.Z/LICENSE-MIT LICENSE -
Update this README with the new version, commit hash, and date.
-
Test the build in IREE.
llhttp.h- Public API header with types, callbacks, and function declarations
llhttp.c- Core parser state machine (auto-generated)api.c- User-facing API functions (init, execute, settings)http.c- HTTP-specific helpers (keep-alive, upgrade detection)
#include "llhttp.h" // Callbacks receive pointers into your buffer (zero-copy) int on_url(llhttp_t* parser, const char* at, size_t length) { printf("URL: %.*s\n", (int)length, at); return 0; } int on_header_field(llhttp_t* parser, const char* at, size_t length) { printf("Header: %.*s\n", (int)length, at); return 0; } int main() { llhttp_t parser; llhttp_settings_t settings; llhttp_settings_init(&settings); settings.on_url = on_url; settings.on_header_field = on_header_field; llhttp_init(&parser, HTTP_REQUEST, &settings); const char* request = "GET /hello HTTP/1.1\r\nHost: example.com\r\n\r\n"; enum llhttp_errno err = llhttp_execute(&parser, request, strlen(request)); if (err != HPE_OK) { fprintf(stderr, "Parse error: %s\n", llhttp_errno_name(err)); return 1; } return 0; }
cc_library( name = "llhttp", srcs = glob(["src/*.c"]), hdrs = ["include/llhttp.h"], includes = ["include"], visibility = ["//visibility:public"], )
add_library(llhttp src/llhttp.c src/api.c src/http.c ) target_include_directories(llhttp PUBLIC include)
(none)