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.
33 lines
684 B
33 lines
684 B
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
|
|
const COUNT = 10;
|
|
|
|
let received = 0;
|
|
|
|
const 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(0, function() {
|
|
const s = net.connect(this.address().port);
|
|
|
|
const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);
|
|
|
|
s.write(big);
|
|
s.resume();
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.strictEqual(received, COUNT);
|
|
});
|
|
|