Skip to content

h3: route addStaticHandler mounts over HTTP/3 (#60) - #65

Merged
EdmondDantes merged 1 commit into
mainfrom
60-h3-mount-routing
May 31, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
60-h3-mount-routing

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

Summary

Completes HTTP/3 static delivery (#60): addStaticHandler mounts are now served over HTTP/3, not just explicit $res->sendFile() (#64).

Wires the protocol-agnostic static FSM into the H3 dispatcher, mirroring the H1/H2 sites almost verbatim:

  • A has_static_mount gate in http3_stream_dispatch calls http_static_try_serve (with a new file-local h3_static_dispatch_cbs) before the user handler.
  • HARD_ZERO — pump owns the request: on_armed pins the stream + in-flight counter, on_static_done runs h3_dispose_tail. No coroutine spawned.
  • HANDLED — inline small-file / 4xx body already set: skip_handler makes the coroutine entry skip the user handler; dispose commits the buffered body.
  • PASSTHROUGH — falls through to the normal handler spawn.
  • Static-only deployments (a mount, no addHttpHandler) now dispatch and synthesize a 404 on miss.

The delivery pump (h3_stream_send_static_response, wired in h3_stream_ops.send_static_response) and the async-refcount discipline are unchanged — reused from #64.

Test

New tests/phpt/server/h3/027-h3-static-mount.phpt: static-only mount over H3 — byte-integrity (sha1) across the 16 KiB chunk boundary (1/16383/16384/16385/50000), index resolution (200), missing (404), traversal (404).

  • Full h3 (27) + static (21) = 50/50 phpt green; 026 (sendFile) stays green.
  • Live server via h3client: 64 KiB asset (async pump), 1 KiB (inline), 404 all correct.
  • 150 sequential requests: 150/150, no leak, server responsive; ~530 concurrent connections: never crashed (refcount handoff holds).

Closes #60.

Wire the protocol-agnostic static FSM into the H3 dispatcher, mirroring
H1/H2: a has_static_mount gate calls http_static_try_serve before the
user handler. HARD_ZERO hands the request to the pump (on_armed pins the
stream, on_static_done runs the dispose tail); HANDLED sets skip_handler
so the coroutine entry skips the handler and dispose commits the buffered
body; PASSTHROUGH falls through. Static-only deployments (mount, no
addHttpHandler) now dispatch and synthesize a 404 on miss.

New phpt 027: mount-routing byte integrity across the 16 KiB boundary +
index + 404, static-only. Full h3 + static suites green (50/50).
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Total lines: 80.51% → 80.71% (+0.20 pp)

File Baseline Current Δ Touched
src/http3/http3_dispatch.c 78.53% 79.65% +1.11 pp ●
src/http3/http3_listener.c 65.42% 69.17% +3.75 pp
src/http_server_class.c 67.53% 68.08% +0.56 pp

@EdmondDantes
EdmondDantes merged commit e5b4c3e into main May 31, 2026
8 checks passed
@EdmondDantes
EdmondDantes deleted the 60-h3-mount-routing branch May 31, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP/3: static delivery (addStaticHandler + $res->sendFile()) is not wired

1 participant