Skip to content

Commit

Permalink
fix: use headers.entries() instead of headers.raw()
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Aug 15, 2023
1 parent ba67f42 commit 2d2d2e2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 3 additions & 1 deletion packages/remix-architect/__tests__/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ describe("architect createRemixHeaders", () => {
describe("creates fetch headers from architect headers", () => {
it("handles empty headers", () => {
let headers = createRemixHeaders({});
expect(headers.raw()).toMatchInlineSnapshot(`Object {}`);
expect(Object.fromEntries(headers.entries())).toMatchInlineSnapshot(
`Object {}`
);
});

it("handles simple headers", () => {
Expand Down
8 changes: 3 additions & 5 deletions packages/remix-architect/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ export async function sendRemixResponse(
let cookies: string[] = [];

// Arc/AWS API Gateway will send back set-cookies outside of response headers.
for (let [key, values] of Object.entries(nodeResponse.headers.raw())) {
nodeResponse.headers.entries().forEach(([key, value]) => {
if (key.toLowerCase() === "set-cookie") {
for (let value of values) {
cookies.push(value);
}
cookies.push(value);
}
}
});

if (cookies.length) {
nodeResponse.headers.delete("Set-Cookie");
Expand Down
4 changes: 3 additions & 1 deletion packages/remix-express/__tests__/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ describe("express createRemixHeaders", () => {
describe("creates fetch headers from express headers", () => {
it("handles empty headers", () => {
let headers = createRemixHeaders({});
expect(headers.raw()).toMatchInlineSnapshot(`Object {}`);
expect(Object.fromEntries(headers.entries())).toMatchInlineSnapshot(
`Object {}`
);
});

it("handles simple headers", () => {
Expand Down
8 changes: 3 additions & 5 deletions packages/remix-express/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ export async function sendRemixResponse(
res.statusMessage = nodeResponse.statusText;
res.status(nodeResponse.status);

for (let [key, values] of Object.entries(nodeResponse.headers.raw())) {
for (let value of values) {
res.append(key, value);
}
}
nodeResponse.headers
.entries()
.forEach(([key, value]) => res.append(key, value));

if (nodeResponse.body) {
await writeReadableStreamToWritable(nodeResponse.body, res);
Expand Down

0 comments on commit 2d2d2e2

Please sign in to comment.