diff --git a/.changeset/fix-content-length-request.md b/.changeset/fix-content-length-request.md new file mode 100644 index 00000000000..3af8993d6da --- /dev/null +++ b/.changeset/fix-content-length-request.md @@ -0,0 +1,5 @@ +--- +"@effect/platform": patch +--- + +fix: stop emitting content-length header in HttpClientRequest.setBody diff --git a/packages/platform/src/internal/httpClientRequest.ts b/packages/platform/src/internal/httpClientRequest.ts index 14fb718c526..bafafc5a870 100644 --- a/packages/platform/src/internal/httpClientRequest.ts +++ b/packages/platform/src/internal/httpClientRequest.ts @@ -394,11 +394,9 @@ export const setBody = dual< if (contentType) { headers = Headers.set(headers, "content-type", contentType) } - - const contentLength = body.contentLength - if (contentLength) { - headers = Headers.set(headers, "content-length", contentLength.toString()) - } + // Do not set content-length here — the transport layer (fetch/undici) + // computes the correct value from what it actually sends on the wire. + // See https://github.com/Effect-TS/effect/issues/6240 } return makeInternal( self.method,