Express + Request Changing headers mid-stream
It seems request has been updated since the accepted answer was submitted, making this process much easier. You can now do the following:
var resource = request('http://example.com');resource.on('response', function(response) { response.headers['Cache-Control'] = 'max-age=60, public';});resource.pipe(res);
Much nicer!
Thanks to Peter Lyons, I was able to get this working using this code:
function(req, res){ request("http://example.com").pipe(res); res.oldWriteHead = res.writeHead; res.writeHead = function(statusCode, reasonPhrase, headers){ res.header('Cache-Control', 'max-age=60, public'); res.oldWriteHead(statusCode, reasonPhrase, headers); }}