Skip to content

Commit e1f2dfc

Browse files
authored
fix(middleware-apply-body-checksum): use lowercase content-md5 header (#2645)
1 parent 96de406 commit e1f2dfc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/middleware-apply-body-checksum/src/applyMd5BodyChecksumMiddleware.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("applyMd5BodyChecksumMiddleware", () => {
2323
});
2424

2525
for (const body of ["body", new ArrayBuffer(10), new Uint8Array(10), void 0]) {
26-
it("should calculate the body hash, encode the result, and set the encoded hash to Content-MD5 header", async () => {
26+
it("should calculate the body hash, encode the result, and set the encoded hash to content-md5 header", async () => {
2727
const handler = applyMd5BodyChecksumMiddleware({
2828
md5: MockHash,
2929
base64Encoder: mockEncoder,
@@ -40,7 +40,7 @@ describe("applyMd5BodyChecksumMiddleware", () => {
4040

4141
expect(next.mock.calls.length).toBe(1);
4242
const { request } = next.mock.calls[0][0];
43-
expect(request.headers["Content-MD5"]).toBe("encoded");
43+
expect(request.headers["content-md5"]).toBe("encoded");
4444
expect(mockHashUpdate.mock.calls).toEqual([[body || ""]]);
4545
});
4646

@@ -65,7 +65,7 @@ describe("applyMd5BodyChecksumMiddleware", () => {
6565
expect(next.mock.calls.length).toBe(1);
6666
const { request } = next.mock.calls[0][0];
6767
expect(request.headers["CoNtEnT-Md5"]).toBe("foo");
68-
expect(request.headers["Content-MD5"]).toBe(undefined);
68+
expect(request.headers["content-md5"]).toBe(undefined);
6969
expect(mockHashUpdate.mock.calls.length).toBe(0);
7070
expect(mockHashDigest.mock.calls.length).toBe(0);
7171
expect(mockEncoder.mock.calls.length).toBe(0);
@@ -90,7 +90,7 @@ describe("applyMd5BodyChecksumMiddleware", () => {
9090
expect(next.mock.calls.length).toBe(1);
9191
const { request } = next.mock.calls[0][0];
9292
expect(request.body).toStrictEqual(new ExoticStream());
93-
expect(request.headers["Content-MD5"]).toBe("encoded");
93+
expect(request.headers["content-md5"]).toBe("encoded");
9494
expect(mockHashDigest.mock.calls.length).toBe(0);
9595
expect(mockEncoder.mock.calls.length).toBe(1);
9696
expect(mockEncoder.mock.calls).toEqual([[new Uint8Array(5)]]);

packages/middleware-apply-body-checksum/src/applyMd5BodyChecksumMiddleware.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const applyMd5BodyChecksumMiddleware =
2020
let { request } = args;
2121
if (HttpRequest.isInstance(request)) {
2222
const { body, headers } = request;
23-
if (!hasHeader("Content-MD5", headers)) {
23+
if (!hasHeader("content-md5", headers)) {
2424
let digest: Promise<Uint8Array>;
2525
if (body === undefined || typeof body === "string" || ArrayBuffer.isView(body) || isArrayBuffer(body)) {
2626
const hash = new options.md5();
@@ -34,7 +34,7 @@ export const applyMd5BodyChecksumMiddleware =
3434
...request,
3535
headers: {
3636
...headers,
37-
"Content-MD5": options.base64Encoder(await digest),
37+
"content-md5": options.base64Encoder(await digest),
3838
},
3939
};
4040
}

0 commit comments

Comments
 (0)