test: use Countdown in test-http-set-cookies
PR-URL: https://github.com/nodejs/node/pull/17504 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
This commit is contained in:
parent
0a0fbd5498
commit
6a089f9357
@ -23,9 +23,9 @@
|
|||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const Countdown = require('../common/countdown');
|
||||||
|
|
||||||
let nresponses = 0;
|
const countdown = new Countdown(2, () => server.close());
|
||||||
|
|
||||||
const server = http.createServer(function(req, res) {
|
const server = http.createServer(function(req, res) {
|
||||||
if (req.url === '/one') {
|
if (req.url === '/one') {
|
||||||
res.writeHead(200, [['set-cookie', 'A'],
|
res.writeHead(200, [['set-cookie', 'A'],
|
||||||
@ -55,9 +55,7 @@ server.on('listening', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.on('end', function() {
|
res.on('end', function() {
|
||||||
if (++nresponses === 2) {
|
countdown.dec();
|
||||||
server.close();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,14 +70,8 @@ server.on('listening', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.on('end', function() {
|
res.on('end', function() {
|
||||||
if (++nresponses === 2) {
|
countdown.dec();
|
||||||
server.close();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('exit', function() {
|
|
||||||
assert.strictEqual(2, nresponses);
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user