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
5 changes: 5 additions & 0 deletions .changeset/alacroix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

Fix response binary content handling
8 changes: 3 additions & 5 deletions packages/open-next/src/core/routing/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ export function convertRes(res: OpenNextNodeResponse): InternalResult {
// When using HEAD requests, it seems that flushHeaders is not called, not sure why
// Probably some kind of race condition
const headers = parseHeaders(res.getFixedHeaders());
const isBase64Encoded = isBinaryContentType(
Array.isArray(headers["content-type"])
? headers["content-type"][0]
: headers["content-type"],
);
const isBase64Encoded =
isBinaryContentType(headers["content-type"]) ||
!!headers["content-encoding"];
// We cannot convert the OpenNextNodeResponse to a ReadableStream directly
// You can look in the `aws-lambda.ts` file for some context
const body = Readable.toWeb(Readable.from(res.getBody()));
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/http/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const parseHeaders = (
if (value === undefined) {
continue;
} else {
result[key] = convertHeader(value);
result[key.toLowerCase()] = convertHeader(value);
}
}

Expand Down
Loading