|
@ -23,15 +23,13 @@ var common = require('../common'); |
|
|
var assert = require('assert'); |
|
|
var assert = require('assert'); |
|
|
var http = require('http'); |
|
|
var http = require('http'); |
|
|
|
|
|
|
|
|
var timeout = 15*1000; |
|
|
|
|
|
var max_requests = 30; |
|
|
|
|
|
var request_number = 0; |
|
|
var request_number = 0; |
|
|
var requests_sent = 0; |
|
|
var requests_sent = 0; |
|
|
var requests_done = 0; |
|
|
var requests_done = 0; |
|
|
var options = { |
|
|
var options = { |
|
|
method: 'GET', |
|
|
method: 'GET', |
|
|
port: common.PORT, |
|
|
port: common.PORT, |
|
|
host: '127.0.0.1' |
|
|
host: '127.0.0.1', |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//http.globalAgent.maxSockets = 15;
|
|
|
//http.globalAgent.maxSockets = 15;
|
|
@ -52,9 +50,7 @@ var server = http.createServer(function(req, res) { |
|
|
server.listen(options.port, options.host, function() { |
|
|
server.listen(options.port, options.host, function() { |
|
|
var req; |
|
|
var req; |
|
|
|
|
|
|
|
|
for (requests_sent = 0; requests_sent < max_requests; |
|
|
for (requests_sent = 0; requests_sent < 30; requests_sent+=1) { |
|
|
requests_sent++) { |
|
|
|
|
|
|
|
|
|
|
|
options.path = '/' + requests_sent; |
|
|
options.path = '/' + requests_sent; |
|
|
req = http.request(options); |
|
|
req = http.request(options); |
|
|
req.id = requests_sent; |
|
|
req.id = requests_sent; |
|
@ -64,7 +60,7 @@ server.listen(options.port, options.host, function() { |
|
|
}); |
|
|
}); |
|
|
res.on('end', function(data) { |
|
|
res.on('end', function(data) { |
|
|
console.log('res#'+this.req.id+' end'); |
|
|
console.log('res#'+this.req.id+' end'); |
|
|
if (++requests_done === max_requests) finish(); |
|
|
requests_done += 1; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
req.on('close', function() { |
|
|
req.on('close', function() { |
|
@ -78,7 +74,7 @@ server.listen(options.port, options.host, function() { |
|
|
var req = this; |
|
|
var req = this; |
|
|
console.log('req#'+this.id + ' timeout'); |
|
|
console.log('req#'+this.id + ' timeout'); |
|
|
req.abort(); |
|
|
req.abort(); |
|
|
if (++requests_done === max_requests) finish(); |
|
|
requests_done += 1; |
|
|
}); |
|
|
}); |
|
|
req.end(); |
|
|
req.end(); |
|
|
} |
|
|
} |
|
|