diff options
author | Subhi Al Hasan <subhialhasan@protonmail.com> | 2021-10-24 13:34:45 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2021-11-09 18:14:52 -0800 |
commit | d8f1823d5fca5e3c00b19530fb15343fdd3c8bf5 (patch) | |
tree | 2b57114c1566f73a2b2c19dea854be190e1daad2 /test/parallel/test-http-upgrade-agent.js | |
parent | b022d192729b801002ef92d8892db80786533ae6 (diff) | |
download | node-new-d8f1823d5fca5e3c00b19530fb15343fdd3c8bf5.tar.gz |
http: change totalSocketCount only on socket creation/close
PR-URL: https://github.com/nodejs/node/pull/40572
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Diffstat (limited to 'test/parallel/test-http-upgrade-agent.js')
-rw-r--r-- | test/parallel/test-http-upgrade-agent.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/parallel/test-http-upgrade-agent.js b/test/parallel/test-http-upgrade-agent.js index 2849881949..d296952243 100644 --- a/test/parallel/test-http-upgrade-agent.js +++ b/test/parallel/test-http-upgrade-agent.js @@ -61,7 +61,12 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { const req = http.request(options); req.end(); + req.on('socket', common.mustCall(function() { + assert.strictEqual(req.agent.totalSocketCount, 1); + })); + req.on('upgrade', common.mustCall(function(res, socket, upgradeHead) { + assert.strictEqual(req.agent.totalSocketCount, 0); let recvData = upgradeHead; socket.on('data', function(d) { recvData += d; @@ -71,14 +76,13 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { assert.strictEqual(recvData.toString(), 'nurtzo'); })); - console.log(res.headers); const expectedHeaders = { 'hello': 'world', 'connection': 'upgrade', 'upgrade': 'websocket' }; assert.deepStrictEqual(expectedHeaders, res.headers); // Make sure this request got removed from the pool. - assert(!(name in http.globalAgent.sockets)); + assert(!(name in req.agent.sockets)); req.on('close', common.mustCall(function() { socket.end(); |