Skip to content

Bun.serve: treat empty header values as absent so auto Content-Type/Date are not duplicated - #35336

Open
robobun wants to merge 7 commits into
mainfrom
farm/c48b394b/serve-empty-header-dup
Open

Bun.serve: treat empty header values as absent so auto Content-Type/Date are not duplicated#35336
robobun wants to merge 7 commits into
mainfrom
farm/c48b394b/serve-empty-header-dup

Extend empty-header-as-absent to static/file routes and put_default

e572adc
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 24, 2026 in 12m 39s

Code review found 2 potential issues

Found 5 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/server/StaticRoute.rs:496-499 Static/file route empty-header handling still diverges from dynamic path
🟡 Nit test/js/bun/http/bun-serve-headers.test.ts:82-106 rawHead / rawHeadStatic are near-duplicates

Annotations

Check warning on line 499 in src/runtime/server/StaticRoute.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Static/file route empty-header handling still diverges from dynamic path

The follow-up commit's `value.length == 0` skip in `StaticRoute::do_write_headers` / `FileRoute::write_headers` applies to *every* snapshot entry, but `WebCore__FetchHeaders__copyTo` flattens common and uncommon headers together — so a static/file route now drops `x-custom: ""` entirely while the dynamic path still emits it (contradicting the PR's "Uncommon (custom) headers are left untouched" and its test, which only covers the dynamic path). Separately, `from_fetch_headers` (headers_jsc.rs:42)

Check warning on line 106 in test/js/bun/http/bun-serve-headers.test.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

rawHead / rawHeadStatic are near-duplicates

`rawHead` (lines 12-33) and `rawHeadStatic` (lines 82-106) are byte-for-byte identical from `net.connect(...)` through `return raw.split(...)` — only the `Bun.serve` options differ. Per REVIEW.md's "the second time a multi-line block appears in your diff, extract a named helper", factor the ~15 lines of socket plumbing into one helper (e.g. `rawHeadFrom(server)` or `rawHead(serveOptions)`) and call it from both.