test: update test-http-upgrade-client to use countdown
PR-URL: https://github.com/nodejs/node/pull/17339 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
parent
2afd4e779c
commit
eb19c6b39f
@ -29,6 +29,7 @@ const assert = require('assert');
|
||||
|
||||
const http = require('http');
|
||||
const net = require('net');
|
||||
const Countdown = require('../common/countdown');
|
||||
|
||||
// Create a TCP server
|
||||
const srv = net.createServer(function(c) {
|
||||
@ -60,7 +61,8 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
|
||||
['Origin', 'http://www.websocket.org']
|
||||
]
|
||||
];
|
||||
let left = headers.length;
|
||||
const countdown = new Countdown(headers.length, () => srv.close());
|
||||
|
||||
headers.forEach(function(h) {
|
||||
const req = http.get({
|
||||
port: port,
|
||||
@ -87,8 +89,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
|
||||
assert.deepStrictEqual(expectedHeaders, res.headers);
|
||||
|
||||
socket.end();
|
||||
if (--left === 0)
|
||||
srv.close();
|
||||
countdown.dec();
|
||||
}));
|
||||
req.on('close', common.mustCall(function() {
|
||||
assert.strictEqual(sawUpgrade, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user