Skip to content

Commit

Permalink
test: fix http-response-multiheaders
Browse files Browse the repository at this point in the history
Make sure the server is not closed until both responses have been
received.

PR-URL: nodejs#3958
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
  • Loading branch information
santigimeno authored and Michael Scovetta committed Apr 2, 2016
1 parent d449e35 commit 2c76789
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/parallel/test-http-response-multiheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const server = http.createServer(function(req, res) {
});

server.listen(common.PORT, common.mustCall(function() {
var count = 0;
for (let n = 1; n <= 2 ; n++) {
// this runs twice, the first time, the server will use
// setHeader, the second time it uses writeHead. The
Expand All @@ -58,7 +59,7 @@ server.listen(common.PORT, common.mustCall(function() {
http.get(
{port:common.PORT, headers:{'x-num': n}},
common.mustCall(function(res) {
if (n == 2) server.close();
if (++ count === 2) server.close();
assert.equal(res.headers['content-length'], 1);
for (const name of norepeat) {
assert.equal(res.headers[name], 'A');
Expand Down

0 comments on commit 2c76789

Please sign in to comment.