mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
806 B
45 lines
806 B
13 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
|
||
|
var http = require('http');
|
||
|
|
||
12 years ago
|
var port = common.PORT;
|
||
|
|
||
13 years ago
|
var server = http.createServer(function(req, res) {
|
||
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||
|
res.end('OK');
|
||
|
});
|
||
|
|
||
|
var agent = new http.Agent({maxSockets: 1});
|
||
|
|
||
|
server.listen(port, function() {
|
||
|
|
||
|
for (var i = 0; i < 11; ++i) {
|
||
|
createRequest().end();
|
||
|
}
|
||
|
|
||
|
function callback(){}
|
||
|
|
||
|
var count = 0;
|
||
|
|
||
|
function createRequest() {
|
||
|
var req = http.request({port: port, path: '/', agent: agent}, function(res) {
|
||
|
|
||
|
req.clearTimeout(callback);
|
||
|
|
||
|
res.on('end', function() {
|
||
|
count++;
|
||
|
|
||
|
if (count == 11) {
|
||
|
server.close();
|
||
|
}
|
||
|
})
|
||
12 years ago
|
|
||
|
res.resume();
|
||
13 years ago
|
});
|
||
|
|
||
|
req.setTimeout(1000, callback);
|
||
|
return req;
|
||
|
}
|
||
|
});
|