dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.72k stars 166 forks source link

fix: intercept fastpath'ed headers through writeHead #137

Closed pimlie closed 4 years ago

pimlie commented 4 years ago

When an app uses res.writeHead then using getHeaders is unreliable as writeHead fast paths headers to the network and doesnt fill the local headers store unless setHeader has been called at least once.

This pr fixes that behaviour by intercepting writeHead because we always need the headers in the local store so we can retrieve them with getHeaders.

For more details, see here: https://nodejs.org/api/http.html#http_response_writehead_statuscode_statusmessage_headers

dougmoscrop commented 4 years ago

awesome!