Skip to content

Commit 40ffcd5

Browse files
authored
fix(cbor): copy headers when building request (#1577)
1 parent 201fcef commit 40ffcd5

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/core": patch
3+
---
4+
5+
copy input headers when building RPCv2 CBOR request
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { buildHttpRpcRequest } from "./parseCborBody";
2+
3+
import { describe, test as it, expect } from "vitest";
4+
5+
describe("buildHttpRpcRequest", () => {
6+
it("should copy the input headers", async () => {
7+
const headers = {
8+
"content-type": "application/cbor",
9+
"smithy-protocol": "rpc-v2-cbor",
10+
accept: "application/cbor",
11+
"content-length": "0",
12+
};
13+
14+
const request = await buildHttpRpcRequest(
15+
{
16+
async endpoint() {
17+
return {
18+
hostname: "https://localhost",
19+
path: "/",
20+
};
21+
},
22+
} as any,
23+
headers,
24+
"/",
25+
"",
26+
""
27+
);
28+
29+
expect(request.headers).toEqual(headers);
30+
expect(request.headers).not.toBe(headers);
31+
});
32+
});

packages/core/src/submodules/cbor/parseCborBody.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ export const buildHttpRpcRequest = async (
100100
port,
101101
method: "POST",
102102
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
103-
headers,
103+
headers: {
104+
// intentional copy.
105+
...headers,
106+
},
104107
};
105108
if (resolvedHostname !== undefined) {
106109
contents.hostname = resolvedHostname;

0 commit comments

Comments
 (0)