Skip to content

Commit 0dd60ed

Browse files
authored
fix(signature-v4): allow empty string as canonical header value (#3797)
1 parent 28dfe63 commit 0dd60ed

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/signature-v4/src/getCanonicalHeaders.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,18 @@ describe("getCanonicalHeaders", () => {
5454
const headers: HeaderBag = {
5555
"x-amz-user-agent": "aws-sdk-js-v3",
5656
host: "foo.us-east-1.amazonaws.com",
57+
":authority": "",
5758
};
5859

59-
(headers.foo as any) = undefined;
6060
const request = new HttpRequest({
6161
method: "POST",
6262
protocol: "https:",
6363
path: "/",
64-
headers,
64+
headers: {
65+
...headers,
66+
foo: undefined,
67+
bar: null,
68+
},
6569
hostname: "foo.us-east-1.amazonaws.com",
6670
});
6771

packages/signature-v4/src/getCanonicalHeaders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const getCanonicalHeaders = (
1212
): HeaderBag => {
1313
const canonical: HeaderBag = {};
1414
for (const headerName of Object.keys(headers).sort()) {
15-
if (!headers[headerName]) {
15+
if (headers[headerName] == undefined) {
1616
continue;
1717
}
1818

0 commit comments

Comments
 (0)