Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 181db33

Browse filesBrowse files
hmammedzadehgibfahn
authored andcommitted
test: update test-http-response-multiheaders to use countdown
PR-URL: #17419 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
1 parent 0813461 commit 181db33
Copy full SHA for 181db33

File tree

Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-http-response-multiheaders.js
+5-3Lines changed: 5 additions & 3 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.