2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2013-04-02 00:46:51 +02:00
|
|
|
var common = require('../common');
|
|
|
|
|
|
|
|
// no warnings should happen!
|
|
|
|
var trace = console.trace;
|
|
|
|
console.trace = function() {
|
|
|
|
trace.apply(console, arguments);
|
|
|
|
throw new Error('no tracing should happen here');
|
|
|
|
};
|
|
|
|
|
|
|
|
var http = require('http');
|
|
|
|
var net = require('net');
|
|
|
|
|
2014-01-23 16:10:24 +01:00
|
|
|
var numRequests = 20;
|
2015-11-26 22:34:11 +01:00
|
|
|
var first = false;
|
2014-01-23 16:10:24 +01:00
|
|
|
|
2013-04-02 00:46:51 +02:00
|
|
|
var server = http.createServer(function(req, res) {
|
2015-11-26 22:34:11 +01:00
|
|
|
if (!first) {
|
|
|
|
first = true;
|
|
|
|
req.socket.on('close', function() {
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
}
|
2013-04-02 00:46:51 +02:00
|
|
|
|
2015-11-26 22:34:11 +01:00
|
|
|
res.end('ok');
|
2013-04-02 00:46:51 +02:00
|
|
|
// Oh no! The connection died!
|
|
|
|
req.socket.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(common.PORT);
|
|
|
|
|
|
|
|
var client = net.connect({ port: common.PORT, allowHalfOpen: true });
|
2014-01-23 16:10:24 +01:00
|
|
|
for (var i = 0; i < numRequests; i++) {
|
2013-04-02 00:46:51 +02:00
|
|
|
client.write('GET / HTTP/1.1\r\n' +
|
2015-05-19 13:00:06 +02:00
|
|
|
'Host: some.host.name\r\n' +
|
2013-04-02 00:46:51 +02:00
|
|
|
'\r\n\r\n');
|
|
|
|
}
|
|
|
|
client.end();
|
|
|
|
client.pipe(process.stdout);
|