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

Lower case request headers (option 2) #684

Merged

Conversation

kibiz0r
Copy link
Contributor

@kibiz0r kibiz0r commented Jul 16, 2024

This is an alternative implementation to #680

Issue #, if available:

Fixes:
#347

Possibly fixes:
#654

Description of changes:

When a request comes in as an API Gateway V1 request, the request headers get passed down as-is. If we are trying to make the req object look like a Node.js HTTP request object, then it should probably include the logic to lower-case all the HTTP headers. Even though we are satisfying the shape of an HTTP object, we aren't satisfying the behavior.

https://nodejs.org/api/http.html#messageheaders

This approach leverages the underlying implementation of http.IncomingMessage, to capture more of the same behavior. Behavior such as lowercasing the header names, joining ones that have duplicates (only technically possible through serverless-express if they differ by case), and providing headersDistinct and rawHeaders in addition to just headers.

Checklist

  • Tests have been added and are passing
  • Documentation has been updated

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -287,7 +321,7 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
const response = await serverlessExpressInstance(event)
const expectedResponse = makeResponse({
eventSourceName,
body: JSON.stringify({ data: { name: name } }),
body: JSON.stringify({ data: { name } }),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter commit hook did this.

@brettstack brettstack merged commit 07f20fb into CodeGenieApp:mainline Aug 7, 2024
5 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 7, 2024
## [4.14.2](v4.14.1...v4.14.2) (2024-08-07)

### Bug Fixes

* leverage native IncomingMessage.headers method ([#684](#684)) ([07f20fb](07f20fb)), closes [#680](#680)
Copy link

github-actions bot commented Aug 7, 2024

🎉 This PR is included in version 4.14.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kibiz0r kibiz0r deleted the lower-case-request-headers branch September 5, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants