From 7bf903fedd3414821aee7c82ce7de97939f99950 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sat, 21 Nov 2015 19:29:59 +0100 Subject: [PATCH] test: fix http-response-multiheaders Make sure the server is not closed until both responses have been received. --- test/parallel/test-http-response-multiheaders.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http-response-multiheaders.js b/test/parallel/test-http-response-multiheaders.js index 6f477d6638105d..4705548d3a385f 100644 --- a/test/parallel/test-http-response-multiheaders.js +++ b/test/parallel/test-http-response-multiheaders.js @@ -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 @@ -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');