Skip to content

fix(fetch): send Content-Length 0 for empty POST requests #92

Description

@speak-agent

Environment

  • mbun 2026.07.18.0
  • Bun compatibility target 1.3.14
  • Linux x86_64

Reproduction

Run the pinned Bun third-party test:

mbun test test/js/third_party/undici-h2/run.test.ts

The plain HTTP case fails with:

actual: content-length:undefined
expected: content-length:0

Analysis

Pinned Bun source in src/http/lib.rs build_request adds Content-Length whenever body_len is nonzero or method.has_request_body is true. This includes an empty POST. The mbun H1 fetch serializer only adds Content-Length when bodyBytes is non-null, so POST with no body emits no framing header.

The pinned third-party test explicitly covers both H1 and H2 and cites RFC 9110 guidance for methods such as POST.

Proposed scope

Add Content-Length: 0 for empty payload methods in the existing H1 fetch serializer while preserving explicit caller headers and leaving GET and HEAD unchanged. Verify the focused H1 test, the full W43 B3 manifest, the JSC member suite, and nearby fetch regressions.

Related to #80. The explicit H2 transport work is tracked separately in #89.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI 主导 | agent-led主要由 agent 完成 / mostly agent-authored缺陷 | bug修复缺陷 / bug fix

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions