Skip to content

Commit

Permalink
test: update test-http-content-length to use countdown
Browse files Browse the repository at this point in the history
PR-URL: #17201
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
  • Loading branch information
Bamieh authored and MylesBorins committed Jan 9, 2018
1 parent d1af106 commit 46f8a9e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/parallel/test-http-content-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require('../common');
const assert = require('assert');
const http = require('http');
const Countdown = require('../common/countdown');

const expectedHeadersMultipleWrites = {
'connection': 'close',
Expand All @@ -18,8 +19,8 @@ const expectedHeadersEndNoData = {
'content-length': '0',
};

let receivedRequests = 0;
const totalRequests = 3;

const countdown = new Countdown(3, () => server.close());

const server = http.createServer(function(req, res) {
res.removeHeader('Date');
Expand All @@ -42,8 +43,7 @@ const server = http.createServer(function(req, res) {
throw new Error('Unreachable');
}

receivedRequests++;
if (totalRequests === receivedRequests) server.close();
countdown.dec();
});

server.listen(0, function() {
Expand Down

0 comments on commit 46f8a9e

Please sign in to comment.