Skip to content

Commit

Permalink
chore: use lowercase headers in middleware-compression
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Sep 24, 2024
1 parent 18dd957 commit 8d6708a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe(compressionMiddleware.name, () => {
body: mockCompressedStream,
headers: {
...mockArgs.request.headers,
"Content-Encoding": "gzip",
"content-encoding": "gzip",
},
},
});
Expand Down Expand Up @@ -130,7 +130,7 @@ describe(compressionMiddleware.name, () => {
body: mockCompressedBody,
headers: {
...mockArgs.request.headers,
"Content-Encoding": "gzip",
"content-encoding": "gzip",
},
},
});
Expand All @@ -148,7 +148,7 @@ describe(compressionMiddleware.name, () => {
request: {
...mockArgs.request,
headers: {
"Content-Encoding": mockExistingContentEncoding,
"content-encoding": mockExistingContentEncoding,
},
},
} as any);
Expand All @@ -160,7 +160,7 @@ describe(compressionMiddleware.name, () => {
body: mockCompressedBody,
headers: {
...mockArgs.request.headers,
"Content-Encoding": [mockExistingContentEncoding, "gzip"].join(","),
"content-encoding": [mockExistingContentEncoding, "gzip"].join(","),
},
},
});
Expand Down
6 changes: 3 additions & 3 deletions packages/middleware-compression/src/compressionMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ export const compressionMiddleware =

if (isRequestCompressed) {
// Either append to the header if it already exists, else set it
if (headers["Content-Encoding"]) {
if (headers["content-encoding"]) {
updatedHeaders = {
...headers,
"Content-Encoding": `${headers["Content-Encoding"]},${algorithm}`,
"content-encoding": `${headers["content-encoding"]},${algorithm}`,
};
} else {
updatedHeaders = { ...headers, "Content-Encoding": algorithm };
updatedHeaders = { ...headers, "content-encoding": algorithm };
}

// We've matched on one supported algorithm in the
Expand Down

0 comments on commit 8d6708a

Please sign in to comment.