Skip to content

Commit 64e30bf

Browse files
committed
avoid creating unnecessary headers instance
1 parent 5d80df6 commit 64e30bf

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/open-next/src/overrides/wrappers/cloudflare-node.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,19 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
4141
}): Writable {
4242
const { statusCode, cookies, headers } = prelude;
4343

44-
const responseHeaders = new Headers(headers);
45-
for (const cookie of cookies) {
46-
responseHeaders.append("Set-Cookie", cookie);
47-
}
44+
headers["Set-Cookie"] = cookies.join(",");
4845

4946
// TODO(vicb): this is a workaround to make PPR work with `wrangler dev`
5047
// See https://github.com/cloudflare/workers-sdk/issues/8004
5148
if (url.hostname === "localhost") {
52-
responseHeaders.set("Content-Encoding", "identity");
49+
headers["Content-Encoding"] = "identity";
5350
}
5451

5552
// Optimize: skip ReadableStream creation for null body statuses
5653
if (NULL_BODY_STATUSES.has(statusCode)) {
5754
const response = new Response(null, {
5855
status: statusCode,
59-
headers: responseHeaders,
56+
headers,
6057
});
6158
resolveResponse(response);
6259

@@ -77,7 +74,7 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
7774

7875
const response = new Response(readable, {
7976
status: statusCode,
80-
headers: responseHeaders,
77+
headers,
8178
});
8279
resolveResponse(response);
8380

0 commit comments

Comments
 (0)