Skip to content

Migrate llhttp as a registered corpus: HTTP/1.x parse engine + std.http.parse_* facade #674

Open

Description

@ehartford

Restated (2026-10-25 triage)

Migrate llhttp as a registered corpus (build/corpora.w) under lib/std/engines/llhttp (D146), with std.http.parse_* as the facade. The #675 blocker is gone.


Original report

⛔ Blocked on #675 — start only after the manifest-driven migration build refactor is complete; llhttp lands as a manifest entry.

Goal

Migrate llhttp (latest release; pin exact version + SHA256 at implementation time) with with migrate, per docs/feature_plans/libs.md engine #42 and its API mapping http.parse_* -> llhttp. Same engine + functionality-named-shim model as #673: the migrated engine is internal; the public surface is std.http.parse_* (or std.http.h1 — naming per libstd-spec conventions), never "llhttp" in any user-facing name.

Motivation

Second link in the web-server chain from docs/impossible_oneliners.md: #658 (runtime sockets) → this (request/response parsing) → ecosystem server package → fetchable with -e dependency. libstd-spec rules "HTTP server → Ecosystem library", but the parser is std (http.parse_* in the plan): production servers stand on it, and HTTP/1.x parsing is where request-smuggling lives (TE/CL conflicts, chunk extensions, obsolete folding) — exactly the code that should come from an engine with a decade of adversarial traffic behind it, not a fresh implementation. llhttp is the only actively-maintained, embeddable, dependency-free candidate; it does zero allocation and no I/O, which makes it an even cleaner migration profile than pcre2.

llhttp-specific notes

  • The release C is generated (from the llparse TS DSL). Treat the pinned release distribution (llhttp.c / api.c / llhttp.h) as the vendored source — exactly what every C consumer of llhttp does. The TS toolchain is out of scope forever; version bumps re-migrate the regenerated release. Mechanically this favors the migrator: flat, macro-light, allocation-free state-machine C (heavy on goto, which with migrate already emits by spec).
  • Callback settings struct (llhttp_settings_t, function pointers) is the one real modeling decision: the shim maps it to With closures/trait; the engine boundary keeps the C shape.
  • Span callbacks are zero-copy views into the caller's buffer. The shim should expose them as With views so escape analysis enforces the no-outliving-the-buffer rule C callers must police by hand.
  • Leniency flags are the CVE surface. The With API is strict by default; lenient toggles are exposed narrowly, individually, and documented as dangerous. No blanket "lenient mode".
  • Port the llhttp test corpus (markdown-driven request/response cases) as conformance fixtures, like pcre2's RunTest ride-along.

Policy (same hard requirements as #673)

  1. with migrate output compiles as-is; any needed change is a generic migrator fix + regression fixture, then re-migrate. Zero hand-patches to migrated files.
  2. Migrator fixes stated in terms of the C construct handled — no llhttp-shaped special cases.
  3. No silent fallbacks: untranslatable constructs fail loudly with function + location.
  4. Engine module-private; only the shim is pub (Migrated pcre2 surface is module-private; jit-unsupported contract test needs a pub API #662 lesson).

Build wiring

Follow the build/pcre2.w pipeline (pinned tarball + SHA256, staged fetch, migrate action, compile-as-is + no-c_export gates, engine-test, promote) — but this is the third instance of the same hand-rolled pipeline, and the declarative migration-manifest refactor under discussion should land first or alongside so llhttp is wired as a manifest entry, not another ~900-line build module. If the refactor is not ready, keep the llhttp build module minimal and factor shared helpers instead of prefix-copying them a third time.

Deliverables

  • Pinned llhttp release + SHA256; reference/fetch/migrate/build/test/promote wiring (manifest entry if the refactor has landed)
  • Migrated engine compiles as-is; migrator improvements land as generic fixes with fixtures
  • std.http parse surface: strict-by-default request/response parser, chunked decoding, keep-alive signaling, zero-copy view spans; leniency toggles narrow and explicit
  • llhttp conformance corpus ported as fixtures
  • libs.md/libstd-spec kept in sync (engine list already names llhttp; add sequencing slot)
  • docs/impossible_oneliners.md server section updated to reflect the remaining chain (Bug: std.net listener and UDP bind APIs are unconditional -1 runtime stubs #658, ecosystem package, fetchable -e dependency)

Spec references

§14.15 channels/HTTP examples for the eventual server surface; §9.1 migrated globals; §16 migration completeness mode; with migrate goto note. Precedents: build/pcre2.w, build/zlib.w, lib/std/re/ + lib/std/regex.w, #673.

Activity

  1. ehartford commented on Jul 16, 2026

    @ehartford
    ContributorAuthor

    Blocked on #675 (manifest-driven migration build refactor). Do not start until #675 is complete — llhttp must be wired as a MigrationSpec manifest entry, not another hand-rolled build module. The "Build wiring" section of this issue is superseded by #675's design; the conditional wording there ("if the refactor is not ready") no longer applies.

  2. added a commit that references this issue on Jul 16, 2026
  3. added this to the post-v0.16.0 milestone on Jul 16, 2026
  4. changed the title [-]Migrate llhttp into the stdlib: HTTP/1.x parse engine + http.parse_* shim (§14.15 server chain)[/-] [+]Migrate llhttp as a registered corpus: HTTP/1.x parse engine + std.http.parse_* facade[/+] on Oct 25, 2026
  5. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): still open, and no longer blocked: #675's design landed as the corpus registry (build/corpora.w, build/corpus.w, f050a9f). No llhttp corpus exists.

    post-release: a new corpus and facade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions