0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-28 22:46:31 +01:00
nodejs/test/parallel/test-cluster-http-pipe.js
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00

43 lines
1.0 KiB
JavaScript

// It is not possible to send pipe handles over the IPC pipe on Windows.
if (process.platform === 'win32') {
process.exit(0);
}
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var http = require('http');
if (cluster.isMaster) {
var ok = false;
var worker = cluster.fork();
worker.on('message', function(msg) {
assert.equal(msg, 'DONE');
ok = true;
});
worker.on('exit', function() {
process.exit();
});
process.on('exit', function() {
assert(ok);
});
return;
}
http.createServer(function(req, res) {
assert.equal(req.connection.remoteAddress, undefined);
assert.equal(req.connection.localAddress, undefined); // TODO common.PIPE?
res.writeHead(200);
res.end('OK');
}).listen(common.PIPE, function() {
var self = this;
http.get({ socketPath: common.PIPE, path: '/' }, function(res) {
res.resume();
res.on('end', function(err) {
if (err) throw err;
process.send('DONE');
process.exit();
});
});
});