-
Notifications
You must be signed in to change notification settings - Fork 667
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
Causing several bugs when empty headers #462
Labels
Comments
codpot
added a commit
to codpot/serverless-express
that referenced
this issue
Sep 23, 2021
Due to in several express.js libraries treats req.headers as NonNullable Object, when event headers is null causing bugs. When incoming headers from API Gateway is null, it should transform to {}. Fix CodeGenieApp#462
This was referenced Sep 23, 2021
brett-vendia
pushed a commit
that referenced
this issue
Oct 13, 2021
🎉 This issue has been resolved in version 4.5.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
OneDev0411
added a commit
to OneDev0411/serverless-express
that referenced
this issue
Mar 16, 2023
## [4.5.1](CodeGenieApp/serverless-express@v4.5.0...v4.5.1) (2021-10-13) ### Bug Fixes * bug when empty event headers ([#462](CodeGenieApp/serverless-express#462)) ([#463](CodeGenieApp/serverless-express#463)) ([2b66164](CodeGenieApp/serverless-express@2b66164))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Due to Node.js
http.IncomingMessage
message.headers is Object, Express.js also returning {} when empty http headers.https://nodejs.org/api/http.html#http_message_headers
https://github.com/expressjs/express/blob/06d11755c99fe4c1cddf8b889a687448b568472d/lib/request.js#L38
https://github.com/expressjs/express/blob/06d11755c99fe4c1cddf8b889a687448b568472d/lib/request.js#L82
So that, several express based libraries treat Express.js
req.headers
as Nonnullable Object.Following line cause problem.
https://github.com/vendia/serverless-express/blob/6adac653fe1daf1dd44ff6aa17dbf08f07662173/src/event-sources/utils.js#L36
AWS Console -> API Gateway -> APIs -> Resources -> Test
with empty Headers causing problems.Also, tested with POST method with empty headers and non-empty body causing problem in serverless-express.
https://github.com/vendia/serverless-express/blob/6adac653fe1daf1dd44ff6aa17dbf08f07662173/src/event-sources/utils.js#L44
TL;DR
When
event.multiValueHeaders
andevent.headers
are null,headers
need to return{}
notnull
.The text was updated successfully, but these errors were encountered: