diff --git a/test/simple/test-domain-http-server.js b/test/simple/test-domain-http-server.js index b337f002dc..666f5d190a 100644 --- a/test/simple/test-domain-http-server.js +++ b/test/simple/test-domain-http-server.js @@ -39,7 +39,7 @@ var server = http.createServer(function(req, res) { dom.on('error', function(er) { serverCaught++; - console.log('server error', er); + console.log('horray! got a server error', er); // try to send a 500. If that fails, oh well. res.writeHead(500, {'content-type':'text/plain'}); res.end(er.stack || er.message || 'Unknown error'); @@ -82,12 +82,7 @@ function next() { dom.on('error', function(er) { clientCaught++; console.log('client error', er); - // kill everything. - dom.dispose(); - }); - - dom.on('dispose', function() { - disposeEmit += 1; + req.socket.destroy(); }); var req = http.get({ host: 'localhost', port: common.PORT, path: p }); @@ -107,6 +102,7 @@ function next() { d += c; }); res.on('end', function() { + console.error('trying to parse json', d); d = JSON.parse(d); console.log('json!', d); }); @@ -117,6 +113,5 @@ function next() { process.on('exit', function() { assert.equal(serverCaught, 2); assert.equal(clientCaught, 2); - assert.equal(disposeEmit, 2); console.log('ok'); }); diff --git a/test/simple/test-http-agent.js b/test/simple/test-http-agent.js index a1ce456e5f..fc66dc49f8 100644 --- a/test/simple/test-http-agent.js +++ b/test/simple/test-http-agent.js @@ -40,10 +40,14 @@ server.listen(common.PORT, function() { setTimeout(function() { for (var j = 0; j < M; j++) { http.get({ port: common.PORT, path: '/' }, function(res) { - console.log(res.statusCode); - if (++responses == N * M) server.close(); + console.log('%d %d', responses, res.statusCode); + if (++responses == N * M) { + console.error('Received all responses, closing server'); + server.close(); + } + res.resume(); }).on('error', function(e) { - console.log(e.message); + console.log('Error!', e); process.exit(1); }); } diff --git a/test/simple/test-http-date-header.js b/test/simple/test-http-date-header.js index 8ed5281712..b11507c017 100644 --- a/test/simple/test-http-date-header.js +++ b/test/simple/test-http-date-header.js @@ -49,6 +49,7 @@ server.addListener('listening', function() { server.close(); process.exit(); }); + res.resume(); }); req.end(); }); diff --git a/test/simple/test-http-default-encoding.js b/test/simple/test-http-default-encoding.js index 4e4741a061..b06f7c83a2 100644 --- a/test/simple/test-http-default-encoding.js +++ b/test/simple/test-http-default-encoding.js @@ -50,6 +50,7 @@ server.listen(common.PORT, function() { method: 'POST' }, function(res) { console.log(res.statusCode); + res.resume(); }).on('error', function(e) { console.log(e.message); process.exit(1); diff --git a/test/simple/test-http-header-read.js b/test/simple/test-http-header-read.js index e844deafcf..3383775922 100644 --- a/test/simple/test-http-header-read.js +++ b/test/simple/test-http-header-read.js @@ -50,5 +50,6 @@ function runTest() { response.on('end', function() { s.close(); }); + response.resume(); }); } diff --git a/test/simple/test-http-host-headers.js b/test/simple/test-http-host-headers.js index 85f07a5685..ca7f70947f 100644 --- a/test/simple/test-http-host-headers.js +++ b/test/simple/test-http-host-headers.js @@ -57,13 +57,14 @@ function testHttp() { var counter = 0; - function cb() { + function cb(res) { counter--; console.log('back from http request. counter = ' + counter); if (counter === 0) { httpServer.close(); testHttps(); } + res.resume(); } httpServer.listen(common.PORT, function(er) { @@ -124,13 +125,14 @@ function testHttps() { var counter = 0; - function cb() { + function cb(res) { counter--; console.log('back from https request. counter = ' + counter); if (counter === 0) { httpsServer.close(); console.log('ok'); } + res.resume(); } httpsServer.listen(common.PORT, function(er) { diff --git a/test/simple/test-http-keep-alive-close-on-header.js b/test/simple/test-http-keep-alive-close-on-header.js index 8fd7348dd5..53c73ae461 100644 --- a/test/simple/test-http-keep-alive-close-on-header.js +++ b/test/simple/test-http-keep-alive-close-on-header.js @@ -44,8 +44,9 @@ server.listen(common.PORT, function() { headers: headers, port: common.PORT, agent: agent - }, function() { + }, function(res) { assert.equal(1, agent.sockets['localhost:' + common.PORT].length); + res.resume(); }); request.on('socket', function(s) { s.on('connect', function() { @@ -60,8 +61,9 @@ server.listen(common.PORT, function() { headers: headers, port: common.PORT, agent: agent - }, function() { + }, function(res) { assert.equal(1, agent.sockets['localhost:' + common.PORT].length); + res.resume(); }); request.on('socket', function(s) { s.on('connect', function() { @@ -80,6 +82,7 @@ server.listen(common.PORT, function() { assert.equal(1, agent.sockets['localhost:' + common.PORT].length); server.close(); }); + response.resume(); }); request.on('socket', function(s) { s.on('connect', function() { diff --git a/test/simple/test-http-keep-alive.js b/test/simple/test-http-keep-alive.js index aa03639deb..4e8a6e816f 100644 --- a/test/simple/test-http-keep-alive.js +++ b/test/simple/test-http-keep-alive.js @@ -42,6 +42,7 @@ server.listen(common.PORT, function() { }, function(response) { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.requests[name].length, 2); + response.resume(); }); http.get({ @@ -49,6 +50,7 @@ server.listen(common.PORT, function() { }, function(response) { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.requests[name].length, 1); + response.resume(); }); http.get({ @@ -59,6 +61,7 @@ server.listen(common.PORT, function() { assert(!agent.requests.hasOwnProperty(name)); server.close(); }); + response.resume(); }); }); diff --git a/test/simple/test-http-many-keep-alive-connections.js b/test/simple/test-http-many-keep-alive-connections.js index 4714cd523c..adbebbdcc4 100644 --- a/test/simple/test-http-many-keep-alive-connections.js +++ b/test/simple/test-http-many-keep-alive-connections.js @@ -55,6 +55,7 @@ server.listen(common.PORT, function() { server.close(); } }); + res.resume(); }).on('error', function(e) { console.log(e.message); process.exit(1); diff --git a/test/simple/test-http-parser-free.js b/test/simple/test-http-parser-free.js index bbf4a50274..7b35781f4d 100644 --- a/test/simple/test-http-parser-free.js +++ b/test/simple/test-http-parser-free.js @@ -44,6 +44,7 @@ server.listen(common.PORT, function() { if (++responses === N) { server.close(); } + res.resume(); }); })(i); } diff --git a/test/simple/test-http-request-end-twice.js b/test/simple/test-http-request-end-twice.js index f33cc6df3d..aa58772226 100644 --- a/test/simple/test-http-request-end-twice.js +++ b/test/simple/test-http-request-end-twice.js @@ -36,6 +36,7 @@ server.listen(common.PORT, function() { assert.ok(!req.end()); server.close(); }); + res.resume(); }); }); diff --git a/test/simple/test-http-request-end.js b/test/simple/test-http-request-end.js index f5da0faf2e..f64dcc305a 100644 --- a/test/simple/test-http-request-end.js +++ b/test/simple/test-http-request-end.js @@ -47,6 +47,7 @@ server.listen(common.PORT, function() { method: 'POST' }, function(res) { console.log(res.statusCode); + res.resume(); }).on('error', function(e) { console.log(e.message); process.exit(1); diff --git a/test/simple/test-http-res-write-end-dont-take-array.js b/test/simple/test-http-res-write-end-dont-take-array.js index f4b3f8ccee..0d68afc3f8 100644 --- a/test/simple/test-http-res-write-end-dont-take-array.js +++ b/test/simple/test-http-res-write-end-dont-take-array.js @@ -53,11 +53,13 @@ var server = http.createServer(function(req, res) { server.listen(common.PORT, function() { // just make a request, other tests handle responses - http.get({port: common.PORT}, function() { + http.get({port: common.PORT}, function(res) { + res.resume(); // lazy serial test, becuase we can only call end once per request test += 1; // do it again to test .end(Buffer); - http.get({port: common.PORT}, function() { + http.get({port: common.PORT}, function(res) { + res.resume(); server.close(); }); }); diff --git a/test/simple/test-http-response-readable.js b/test/simple/test-http-response-readable.js index b31fcc3d12..b48c06fb40 100644 --- a/test/simple/test-http-response-readable.js +++ b/test/simple/test-http-response-readable.js @@ -35,6 +35,7 @@ testServer.listen(common.PORT, function() { assert.equal(res.readable, false, 'res.readable set to false after end'); testServer.close(); }); + res.resume(); }); }); diff --git a/test/simple/test-http-set-trailers.js b/test/simple/test-http-set-trailers.js index a0896df5ac..445a3eeaac 100644 --- a/test/simple/test-http-set-trailers.js +++ b/test/simple/test-http-set-trailers.js @@ -106,6 +106,7 @@ server.on('listening', function() { process.exit(); } }); + res.resume(); }); outstanding_reqs++; }); diff --git a/test/simple/test-http-status-code.js b/test/simple/test-http-status-code.js index 395623869f..ca56230d26 100644 --- a/test/simple/test-http-status-code.js +++ b/test/simple/test-http-status-code.js @@ -59,6 +59,7 @@ function nextTest() { testIdx += 1; nextTest(); }); + response.resume(); }); } diff --git a/test/simple/test-http-timeout.js b/test/simple/test-http-timeout.js index 5170d795aa..c68a465f33 100644 --- a/test/simple/test-http-timeout.js +++ b/test/simple/test-http-timeout.js @@ -55,6 +55,8 @@ server.listen(port, function() { server.close(); } }) + + res.resume(); }); req.setTimeout(1000, callback); diff --git a/test/simple/test-https-agent.js b/test/simple/test-https-agent.js index b54d5c38ae..34fa15c737 100644 --- a/test/simple/test-https-agent.js +++ b/test/simple/test-https-agent.js @@ -54,6 +54,7 @@ server.listen(common.PORT, function() { port: common.PORT, rejectUnauthorized: false }, function(res) { + res.resume(); console.log(res.statusCode); if (++responses == N * M) server.close(); }).on('error', function(e) { diff --git a/test/simple/test-https-socket-options.js b/test/simple/test-https-socket-options.js index 4487cf8fa4..21b1118f7d 100644 --- a/test/simple/test-https-socket-options.js +++ b/test/simple/test-https-socket-options.js @@ -55,6 +55,7 @@ server_http.listen(common.PORT, function() { rejectUnauthorized: false }, function(res) { server_http.close(); + res.resume(); }); // These methods should exist on the request and get passed down to the socket req.setNoDelay(true); @@ -77,6 +78,7 @@ server_https.listen(common.PORT+1, function() { rejectUnauthorized: false }, function(res) { server_https.close(); + res.resume(); }); // These methods should exist on the request and get passed down to the socket req.setNoDelay(true); diff --git a/test/simple/test-https-strict.js b/test/simple/test-https-strict.js index 43febc8e13..720b0a6db7 100644 --- a/test/simple/test-https-strict.js +++ b/test/simple/test-https-strict.js @@ -170,6 +170,7 @@ function makeReq(path, port, error, host, ca) { server2.close(); server3.close(); } + res.resume(); }) } diff --git a/test/simple/test-regress-GH-877.js b/test/simple/test-regress-GH-877.js index d431118fdf..1cdca9f7db 100644 --- a/test/simple/test-regress-GH-877.js +++ b/test/simple/test-regress-GH-877.js @@ -48,6 +48,7 @@ server.listen(common.PORT, '127.0.0.1', function() { if (++responses == N) { server.close(); } + res.resume(); }); assert.equal(req.agent, agent);