Is There a Way to Check Sent Headers with Node/ Express 2.x? Is There a Way to Check Sent Headers with Node/ Express 2.x? express express

Is There a Way to Check Sent Headers with Node/ Express 2.x?


The HTTP response is a WritableStream. When the stream closes, a finish event is emitted. Thus listening to it does the trick:

res.on('finish', function() {    console.log(res._headers);});

Much more flexible. Can be put in a middleware or a resource handler.


As @generalhenry stated on my question comments:

stream.pipe(res).on('end', function () {  console.log(res._headers); });

The above line worked for me.


res.set("Content-disposition", "attachment; filename=\""+file.name+"\"")

This worked for me.