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 <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
  • Loading branch information
Bamieh authored and gibfahn committed Jan 24, 2018
1 parent 2f35920 commit 6ed5773
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 6ed5773

Please sign in to comment.