2010-03-09 00:06:29 +01:00
|
|
|
require("../common");
|
2009-08-05 11:17:26 +02:00
|
|
|
|
2010-05-09 22:54:58 +02:00
|
|
|
http = require("http");
|
|
|
|
|
2009-08-05 11:17:26 +02:00
|
|
|
var request_count = 1000;
|
2010-05-09 22:54:58 +02:00
|
|
|
var body = '{"ok": true}';
|
2009-08-05 11:17:26 +02:00
|
|
|
|
2010-05-09 22:54:58 +02:00
|
|
|
var server = http.createServer(function(req, res) {
|
|
|
|
res.writeHead(200, {'Content-Type': 'text/javascript'});
|
|
|
|
res.write(body);
|
|
|
|
res.end();
|
2009-08-05 11:17:26 +02:00
|
|
|
});
|
2010-05-09 22:54:58 +02:00
|
|
|
server.listen(PORT);
|
2009-08-05 11:17:26 +02:00
|
|
|
|
|
|
|
var requests_ok = 0;
|
|
|
|
var requests_complete = 0;
|
|
|
|
|
2010-05-09 22:54:58 +02:00
|
|
|
server.addListener('listening', function () {
|
2009-08-05 11:17:26 +02:00
|
|
|
for (var i = 0; i < request_count; i++) {
|
2010-05-09 22:54:58 +02:00
|
|
|
http.cat('http://localhost:'+PORT+'/', 'utf8', function (err, content) {
|
|
|
|
requests_complete++;
|
|
|
|
if (err) {
|
|
|
|
print("-");
|
|
|
|
} else {
|
|
|
|
assert.equal(body, content)
|
2009-08-05 11:17:26 +02:00
|
|
|
print(".");
|
|
|
|
requests_ok++;
|
2010-05-09 22:54:58 +02:00
|
|
|
}
|
|
|
|
if (requests_complete == request_count) {
|
2010-06-24 02:40:51 +02:00
|
|
|
console.log("\nrequests ok: " + requests_ok);
|
2010-05-09 22:54:58 +02:00
|
|
|
server.close();
|
|
|
|
}
|
|
|
|
});
|
2009-08-05 11:17:26 +02:00
|
|
|
}
|
2010-05-09 22:54:58 +02:00
|
|
|
});
|
2009-08-05 11:17:26 +02:00
|
|
|
|
2009-10-29 23:59:35 +01:00
|
|
|
process.addListener("exit", function () {
|
2010-05-09 22:54:58 +02:00
|
|
|
assert.equal(request_count, requests_complete);
|
|
|
|
assert.equal(request_count, requests_ok);
|
2009-10-29 23:59:35 +01:00
|
|
|
});
|