mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
http: remove default 'timeout' listener on upgrade
Remove the default listener of the `'timeout'` event from the socket before emitting the `'connect'` or `'upgrade'` event. PR-URL: https://github.com/nodejs/node/pull/26030 Fixes: https://github.com/nodejs/node/issues/23857 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
a18e27df9e
commit
d5577f0395
@ -465,6 +465,10 @@ function socketOnData(d) {
|
||||
socket.removeListener('data', socketOnData);
|
||||
socket.removeListener('end', socketOnEnd);
|
||||
socket.removeListener('drain', ondrain);
|
||||
|
||||
if (req.timeoutCb)
|
||||
socket.removeListener('timeout', req.timeoutCb);
|
||||
|
||||
parser.finish();
|
||||
freeParser(parser, req, socket);
|
||||
|
||||
|
@ -568,6 +568,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) {
|
||||
socket.removeListener('drain', state.onDrain);
|
||||
socket.removeListener('drain', ondrain);
|
||||
socket.removeListener('error', socketOnError);
|
||||
socket.removeListener('timeout', socketOnTimeout);
|
||||
unconsume(parser, socket);
|
||||
parser.finish();
|
||||
freeParser(parser, req, socket);
|
||||
|
@ -36,6 +36,7 @@ server.on('connect', common.mustCall((req, socket, firstBodyChunk) => {
|
||||
assert.strictEqual(socket.listenerCount('data'), 0);
|
||||
assert.strictEqual(socket.listenerCount('end'), 1);
|
||||
assert.strictEqual(socket.listenerCount('error'), 0);
|
||||
assert.strictEqual(socket.listenerCount('timeout'), 0);
|
||||
|
||||
socket.write('HTTP/1.1 200 Connection established\r\n\r\n');
|
||||
|
||||
@ -53,7 +54,8 @@ server.listen(0, common.mustCall(() => {
|
||||
const req = http.request({
|
||||
port: server.address().port,
|
||||
method: 'CONNECT',
|
||||
path: 'google.com:443'
|
||||
path: 'google.com:443',
|
||||
timeout: 20000
|
||||
}, common.mustNotCall());
|
||||
|
||||
req.on('socket', common.mustCall((socket) => {
|
||||
@ -80,6 +82,7 @@ server.listen(0, common.mustCall(() => {
|
||||
assert.strictEqual(socket.listenerCount('close'), 0);
|
||||
assert.strictEqual(socket.listenerCount('error'), 0);
|
||||
assert.strictEqual(socket.listenerCount('agentRemove'), 0);
|
||||
assert.strictEqual(socket.listenerCount('timeout'), 0);
|
||||
|
||||
let data = firstBodyChunk.toString();
|
||||
socket.on('data', (buf) => {
|
||||
|
Loading…
Reference in New Issue
Block a user