0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/disabled/test-http-stress.js
Oleg Efimov 093dfaf801 GJSLint all tests, only 3 long lines left in test-url.js
test/simple/test-url.js:31:(0110) Line too long (82 characters).
test/simple/test-url.js:39:(0110) Line too long (85 characters).
test/simple/test-url.js:40:(0110) Line too long (92 characters).
2010-12-05 15:42:41 -08:00

43 lines
1.1 KiB
JavaScript

var common = require('../common');
var assert = require('assert');
var http = require('http');
var request_count = 1000;
var body = '{"ok": true}';
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/javascript'});
res.write(body);
res.end();
});
server.listen(common.PORT);
var requests_ok = 0;
var requests_complete = 0;
server.addListener('listening', function() {
for (var i = 0; i < request_count; i++) {
http.cat('http://localhost:' + common.PORT + '/', 'utf8',
function(err, content) {
requests_complete++;
if (err) {
common.print('-');
} else {
assert.equal(body, content);
common.print('.');
requests_ok++;
}
if (requests_complete == request_count) {
console.log('\nrequests ok: ' + requests_ok);
server.close();
}
});
}
});
process.addListener('exit', function() {
assert.equal(request_count, requests_complete);
assert.equal(request_count, requests_ok);
});