Skip to content

Commit

Permalink
fix(api-gateway-v1): force lower case for headers
Browse files Browse the repository at this point in the history
fix(api-gateway-v1): force headers to lower case
  • Loading branch information
H4ad committed Jun 21, 2022
1 parent 9450ec6 commit 4a271db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/adapters/aws/api-gateway-v1.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import {
getDefaultIfUndefined,
getEventBodyAsBuffer,
getFlattenedHeadersMap,
getMultiValueHeadersMap,
getPathWithQueryStringParams,
} from '../../core';
Expand Down Expand Up @@ -87,8 +88,8 @@ export class ApiGatewayV1Adapter
partialEventV1.version !== '2.0' &&
partialEventV1.headers &&
partialEventV1.multiValueHeaders &&
(partialEventV1.queryStringParameters ===
partialEventV1.multiValueQueryStringParameters ||
((partialEventV1.queryStringParameters === null &&
partialEventV1.multiValueQueryStringParameters === null) ||
(partialEventV1.queryStringParameters &&
partialEventV1.multiValueQueryStringParameters))
);
Expand All @@ -99,7 +100,7 @@ export class ApiGatewayV1Adapter
*/
public getRequest(event: APIGatewayProxyEvent): AdapterRequest {
const method = event.httpMethod;
const headers = event.headers;
const headers = getFlattenedHeadersMap(event.headers, ',', true);
const path = this.getPathFromEvent(event);

let body: Buffer | undefined;
Expand Down
2 changes: 2 additions & 0 deletions test/adapters/aws/api-gateway-v1.adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ describe(ApiGatewayV1Adapter.name, () => {

expect(result).toHaveProperty('method', method);
expect(result).toHaveProperty('headers');
expect(result.headers).not.toHaveProperty('Accept');
expect(result.headers).toHaveProperty('accept');

expect(result).toHaveProperty('body');
expect(result.body).toBeInstanceOf(Buffer);
Expand Down

0 comments on commit 4a271db

Please sign in to comment.