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.
55 lines
1.1 KiB
55 lines
1.1 KiB
10 years ago
|
'use strict';
|
||
|
|
||
|
var path = require('path');
|
||
|
var http = require('http');
|
||
|
var fs = require('fs');
|
||
|
var spawn = require('child_process').spawn;
|
||
|
var common = require('../common.js')
|
||
|
var test = require('../../test/common.js')
|
||
10 years ago
|
var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js';
|
||
10 years ago
|
var PIPE = test.PIPE;
|
||
|
|
||
10 years ago
|
try {
|
||
|
fs.accessSync(test.tmpDir, fs.F_OK);
|
||
|
} catch (e) {
|
||
|
fs.mkdirSync(test.tmpDir);
|
||
|
}
|
||
|
|
||
10 years ago
|
var server;
|
||
|
try {
|
||
|
fs.unlinkSync(PIPE);
|
||
|
} catch (e) { /* ignore */ }
|
||
|
|
||
|
server = http.createServer(function(req, res) {
|
||
|
res.writeHead(200, { 'content-type': 'text/plain',
|
||
|
'content-length': '2' });
|
||
|
res.end('ok');
|
||
|
});
|
||
|
|
||
|
server.on('error', function(err) {
|
||
|
throw new Error('server error: ' + err);
|
||
|
});
|
||
|
|
||
|
try {
|
||
|
var child;
|
||
|
|
||
|
server.listen(PIPE);
|
||
|
|
||
|
child = spawn(process.execPath, [pep], { });
|
||
|
|
||
|
child.on('error', function(err) {
|
||
|
throw new Error('spawn error: ' + err );
|
||
|
});
|
||
|
|
||
|
child.stdout.pipe(process.stdout);
|
||
10 years ago
|
child.stderr.pipe(process.stderr);
|
||
10 years ago
|
|
||
10 years ago
|
child.on('close', function (exitCode) {
|
||
|
server.close();
|
||
10 years ago
|
});
|
||
|
|
||
|
} catch(e) {
|
||
|
throw new Error('error: ' + e );
|
||
|
}
|
||
|
|