Skip to content

Commit

Permalink
only specify content-length in certain cases
Browse files Browse the repository at this point in the history
will now only set the content-length header if the request has a body and the header is not already set
  • Loading branch information
HotelCalifornia authored Jun 19, 2018
1 parent 5d8c486 commit 1ef34b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function mapApiGatewayEventToHttpRequest(event, context, socketPath) {
const eventWithoutBody = Object.assign({}, event)
delete eventWithoutBody.body

headers['Content-Length'] = Buffer.byteLength(event.body)
if (event.body && !headers['Content-Length']) {
headers['Content-Length'] = Buffer.byteLength(event.body)
}
headers['x-apigateway-event'] = encodeURIComponent(JSON.stringify(eventWithoutBody))
headers['x-apigateway-context'] = encodeURIComponent(JSON.stringify(context))

Expand Down

0 comments on commit 1ef34b8

Please sign in to comment.