Repository navigation
Describe the bug
Pipe cache-Control header response is not sets in the latest got version, as it used to be in got version 10.7.0 Actual behaviorCache-Control is not sets as it used to be in got version 10.7.0 Expected behaviorCache-Control" header = "public, max-age=123456" Code to reproduceconst got = require('got'); const client = got.extend({ app.get('/', async (req, res) => { }); got('http://localhost:3000').then(response => { ...{ } Checklist
|
Replies: 3 comments
|
Please format the issue properly. |
|
I can't update the original issue, as I'm not the owner. But I'm pasting a simplified and edited version of the above code here, to reproduce the issue const got = require('got');
const expect = require('chai').expect;
const express = require('express');
const app = express();
app.get('/', async (req, res) => {
const readStream = got.stream('https://www.youtube.com/watch?v=RimGVSA_38o');
readStream.on("response", ()=> {
res.setHeader("Cache-Control", "public, max-age=123456");
}).on('error', (err) => {
console.log('Error in read stream...', err);
});
readStream.pipe(res);
});
app.listen(3000);
got('http://localhost:3000').then(response => {
expect(response.headers["cache-control"]).to.equal("public, max-age=123456");
console.log('Succedded');
}); |
|
This is not a regression. See szmarczak@d64298c Got passes the headers it has received from the response after emitting the |
This is not a regression. See szmarczak@d64298c
Got passes the headers it has received from the response after emitting the
responseevent, so you can modify the response object. If you don't want to alter it, you need to listen for theendevent instead.