From dbec9265608cd3af3740f35e280cb2d088a48d25 Mon Sep 17 00:00:00 2001 From: Majid Burney Date: Mon, 23 Jan 2023 16:39:42 -0800 Subject: [PATCH] Add failing test for issue #1760 --- test/node/redirects.js | 14 ++++++++++++++ test/support/server.js | 1 + 2 files changed, 15 insertions(+) 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'); });