diff --git a/test/node/redirects.js b/test/node/redirects.js index 7dff60fe8..2ff8e8edc 100644 --- a/test/node/redirects.js +++ b/test/node/redirects.js @@ -71,6 +71,20 @@ describe('request', () => { }); }); + it('should overwrite previously set cookie during a redirect when agent is used', (done) => { + const agent = request.agent(); + agent.get(`${base}/set-cookie`).end((error) => { + assert.ifError(error); + agent + .get(`${base}/cookie-redirect`) + .redirects(1) + .end((error, res) => { + assert.ifError(error); + assert(/replaced=yes/.test(res.text), 'replaced=yes'); + }); + }); + }) + it('should follow Location', (done) => { const redirects = []; diff --git a/test/support/server.js b/test/support/server.js index 159da2753..a219c0d15 100644 --- a/test/support/server.js +++ b/test/support/server.js @@ -419,6 +419,7 @@ app.get('/cookie-redirect', (request, res) => { }); app.get('/set-cookie', (request, res) => { + res.cookie('replaced', 'no') res.cookie('persist', '123'); res.send('ok'); });