Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(middleware-eventstream): lowercase headers more consistently #6259

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const mockHandle = jest.fn().mockResolvedValue({
response: new HttpResponse({
statusCode: 200,
headers: {
"Content-Type": "application/json",
"content-type": "application/json",
},
body: Readable.from([""]),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe(getCredentials.name, () => {
const response = new HttpResponse({
statusCode: 200,
headers: {
"Content-Type": "application/json",
"content-type": "application/json",
},
body: Readable.from(JSON.stringify(data)),
});
Expand All @@ -34,7 +34,7 @@ describe(getCredentials.name, () => {
const response = new HttpResponse({
statusCode: 400,
headers: {
"Content-Type": "application/json",
"content-type": "application/json",
},
body: Readable.from(
JSON.stringify({
Expand All @@ -57,7 +57,7 @@ describe(getCredentials.name, () => {
const response = new HttpResponse({
statusCode: 500,
headers: {
"Content-Type": "json",
"content-type": "json",
},
body: Readable.from(JSON.stringify({})),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const eventStreamHeaderMiddleware: BuildMiddleware<any, any> = (next) =>
if (!HttpRequest.isInstance(request)) return next(args);
request.headers = {
...request.headers,
"Content-Type": "application/vnd.amazon.eventstream",
"content-type": "application/vnd.amazon.eventstream",
"x-amz-content-sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS",
};
return next({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("middleware-eventstream", () => {

requireRequestsFrom(client).toMatch({
headers: {
"Content-Type": "application/vnd.amazon.eventstream",
"content-type": "application/vnd.amazon.eventstream",
"x-amz-content-sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS",
},
});
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("middleware-eventstream", () => {

requireRequestsFrom(client).toMatch({
headers: {
"Content-Type": "application/vnd.amazon.eventstream",
"content-type": "application/vnd.amazon.eventstream",
"x-amz-content-sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS",
},
});
Expand Down Expand Up @@ -83,7 +83,7 @@ describe("middleware-eventstream", () => {

requireRequestsFrom(client).toMatch({
headers: {
"Content-Type": "application/vnd.amazon.eventstream",
"content-type": "application/vnd.amazon.eventstream",
"x-amz-content-sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS",
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("middleware-sdk-transcribe-streaming", () => {

requireRequestsFrom(client).toMatch({
headers: {
"Content-Type": /undefined/,
"content-type": /undefined/,
host: "transcribestreaming.us-west-2.amazonaws.com:8443",
},
query: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe(websocketEndpointMiddleware.name, () => {
const request = new HttpRequest({
headers: {
"content-type": "application/vnd.amazon.eventstream",
"Content-Type": "application/vnd.amazon.eventstream",
"content-type": "application/vnd.amazon.eventstream",
kuhe marked this conversation as resolved.
Show resolved Hide resolved
"x-amz-content-sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS",
"X-Amz-Content-Sha256": "STREAMING-AWS4-HMAC-SHA256-EVENTS",
},
Expand All @@ -51,7 +51,6 @@ describe(websocketEndpointMiddleware.name, () => {
expect(HttpRequest.isInstance(args.request)).toBeTruthy();
const processed = args.request as HttpRequest;
expect(processed.headers["content-type"]).toBeUndefined();
expect(processed.headers["Content-Type"]).toBeUndefined();
trivikr marked this conversation as resolved.
Show resolved Hide resolved
expect(processed.headers["x-amz-content-sha256"]).toBeUndefined();
expect(processed.headers["X-Amz-Content-Sha256"]).toBeUndefined();
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const websocketEndpointMiddleware =
// 'Content-Type' and 'x-amz-content-sha256' headers are normally set for
// event stream, but WebSocket doesn't require it.
// See: 'eventStreamHeaderMiddleware' in @aws-sdk/middleware-eventstream
delete headers["Content-Type"];
delete headers["content-type"];
delete headers["x-amz-content-sha256"];

for (const name of Object.keys(headers)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("middleware-websocket", () => {
path: "/start-face-liveness-session-websocket",
headers: {
host: "streaming-rekognition.us-west-2.amazonaws.com",
"Content-Type": /^undefined$/,
"content-type": /^undefined$/,
"x-amz-content-sha256": /^undefined$/,
"user-agent": /^aws-sdk-js/,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/s3-request-presigner/src/presigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("s3 presigner", () => {
...minimalRequest,
headers: {
...minimalRequest.headers,
"Content-Type": "application/octet-stream",
"content-type": "application/octet-stream",
},
};
const signed = await signer.presign(requestWithContentTypeHeader, presigningOptions);
Expand Down
Loading