Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/giant-days-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@opennextjs/aws": patch
---

fix(http): Set content-length only if body is present

The body is undefined when using the edge converter and the method is GET or HEAD
6 changes: 4 additions & 2 deletions packages/open-next/src/http/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export class IncomingMessage extends http.IncomingMessage {
destroy: Function.prototype,
});

if (typeof headers["content-length"] === "undefined") {
headers["content-length"] = Buffer.byteLength(body).toString();
// Set the content length when there is a body.
// See https://httpwg.org/specs/rfc9110.html#field.content-length
if (body) {
headers["content-length"] ??= String(Buffer.byteLength(body));
}

Object.assign(this, {
Expand Down