Skip to content

Commit 5fecdba

Browse files
hmammedzadehMylesBorins
hmammedzadeh
authored andcommitted
test: update test-http-response-multiheaders to use countdown
PR-URL: #17419 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jon Moss <[email protected]>
1 parent 69e775d commit 5fecdba

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/parallel/test-http-response-multiheaders.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
const http = require('http');
55
const assert = require('assert');
6+
const Countdown = require('../common/countdown');
67

78
// Test that certain response header fields do not repeat.
89
// 'content-length' should also be in this list but it is
@@ -27,6 +28,7 @@ const norepeat = [
2728
'age',
2829
'expires'
2930
];
31+
const runCount = 2;
3032

3133
const server = http.createServer(function(req, res) {
3234
const num = req.headers['x-num'];
@@ -47,8 +49,8 @@ const server = http.createServer(function(req, res) {
4749
});
4850

4951
server.listen(0, common.mustCall(function() {
50-
let count = 0;
51-
for (let n = 1; n <= 2; n++) {
52+
const countdown = new Countdown(runCount, () => server.close());
53+
for (let n = 1; n <= runCount; n++) {
5254
// this runs twice, the first time, the server will use
5355
// setHeader, the second time it uses writeHead. The
5456
// result on the client side should be the same in
@@ -58,7 +60,7 @@ server.listen(0, common.mustCall(function() {
5860
http.get(
5961
{ port: this.address().port, headers: { 'x-num': n } },
6062
common.mustCall(function(res) {
61-
if (++count === 2) server.close();
63+
countdown.dec();
6264
for (const name of norepeat) {
6365
assert.strictEqual(res.headers[name], 'A');
6466
}

0 commit comments

Comments
 (0)