Skip to content

fix(platform): stop emitting content-length in HttpClientRequest.setBody#6265

Open
sijie-Z wants to merge 2 commits into
Effect-TS:mainfrom
sijie-Z:fix/remove-content-length-from-request
Open

fix(platform): stop emitting content-length in HttpClientRequest.setBody#6265
sijie-Z wants to merge 2 commits into
Effect-TS:mainfrom
sijie-Z:fix/remove-content-length-from-request

Conversation

@sijie-Z

@sijie-Z sijie-Z commented Jun 9, 2026

Copy link
Copy Markdown

Type

  • Bug Fix

Description

HttpClientRequest.setBody currently emits a content-length header from body.contentLength when building a request.

This can conflict with the behavior of the underlying transport layer (fetch / undici), which is responsible for determining the actual bytes sent on the wire and setting the corresponding Content-Length header when appropriate.

This change removes the automatic content-length header emission from setBody and leaves content length calculation to the transport implementation.

Users who need to explicitly control the header can still set it manually through request headers.

Related

sijie-Z added 2 commits June 8, 2026 22:03
The transport layer (fetch/undici) is responsible for computing
Content-Length from what it actually sends on the wire. Setting it
preemptively from body.contentLength causes wire mismatches with
undici 8.2+ which stopped auto-overriding caller-supplied headers.

Fixes Effect-TS#6240
@sijie-Z sijie-Z requested a review from tim-smart as a code owner June 9, 2026 08:08
@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jun 9, 2026
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 259b088

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/platform Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@truffle-dev

Copy link
Copy Markdown

Confirmed at 259b0887248b3e04f633c77a7cc38d61841ad536. The diff removes exactly the four lines I named in #6240 and leaves the server-side emission at packages/platform/src/internal/httpServerResponse.ts:43-50 alone, which is the right shape.

One tightening before merge: a regression test in packages/platform/test/HttpClient.test.ts asserting that a request whose body went through setBody has no content-length in its headers. The file has no current coverage for setBody header side-effects, so a future refactor that re-introduced the emission would not fail any existing test.

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

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

@effect/platform: HttpClientRequest emits explicit Content-Length, causing wire mismatches under undici 8.2+

2 participants