From cbf0a52baa320ebe87af9da80b2b8930aac98c05 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 2 Jan 2023 14:22:49 +0100 Subject: [PATCH] fix: don't send keep-alive if we want reset (#1846) --- lib/client.js | 2 +- test/proxy-agent.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index dd9531f93b4..9de7ff721cb 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1395,7 +1395,7 @@ function write (client, request) { if (upgrade) { header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n` - } else if (client[kPipelining]) { + } else if (client[kPipelining] && !socket[kReset]) { header += 'connection: keep-alive\r\n' } else { header += 'connection: close\r\n' diff --git a/test/proxy-agent.js b/test/proxy-agent.js index 7fc29eafea7..03156395eff 100644 --- a/test/proxy-agent.js +++ b/test/proxy-agent.js @@ -323,7 +323,7 @@ test('ProxyAgent correctly sends headers when using fetch - #1355, #1623', { ski const expectedProxyHeaders = { host: `localhost:${proxy.address().port}`, - connection: 'keep-alive' + connection: 'close' } proxy.on('connect', (req, res) => {