Skip to content

Commit

Permalink
test: fix http-many-ended-pipelines server close
Browse files Browse the repository at this point in the history
The test was calling server.close() without waiting for the server
to have received all the requests. This would cause an ECONNRESET.
  • Loading branch information
orangemocha authored and tjfontaine committed Jan 23, 2014
1 parent 5aebc73 commit 5d4f4ee
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/simple/test-http-many-ended-pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,25 @@ console.trace = function() {
var http = require('http');
var net = require('net');

var numRequests = 20;
var done = 0;

var server = http.createServer(function(req, res) {
res.end('ok');

// Oh no! The connection died!
req.socket.destroy();
if (++done == numRequests)
server.close();
});

server.listen(common.PORT);

var client = net.connect({ port: common.PORT, allowHalfOpen: true });
for (var i = 0; i < 20; i++) {
for (var i = 0; i < numRequests; i++) {
client.write('GET / HTTP/1.1\r\n' +
'Host: some.host.name\r\n'+
'\r\n\r\n');
}
client.end();
client.on('connect', function() {
server.close();
});
client.pipe(process.stdout);

0 comments on commit 5d4f4ee

Please sign in to comment.