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.
When an app uses
res.writeHead
then usinggetHeaders
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