node/test/parallel/test-http-pipeline-regr-2639.js
Jackson Tian 4d78121b77 lib: simplify code with String.prototype.repeat()
use String.prototype.repeat() to simplify code, less code,
more semantically.

PR-URL: https://github.com/nodejs/node/pull/5359
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-21 16:42:58 -07:00

34 lines
691 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');
const COUNT = 10;
var received = 0;
var server = http.createServer(function(req, res) {
// Close the server, we have only one TCP connection anyway
if (received++ === 0)
server.close();
res.writeHead(200);
res.write('data');
setTimeout(function() {
res.end();
}, (Math.random() * 100) | 0);
}).listen(common.PORT, function() {
const s = net.connect(common.PORT);
var big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);
s.write(big);
s.resume();
});
process.on('exit', function() {
assert.equal(received, COUNT);
});