parent
627f379f22
commit
87286cc737
@ -641,7 +641,7 @@ var commands = [
|
|||||||
'out (o)',
|
'out (o)',
|
||||||
'backtrace (bt)',
|
'backtrace (bt)',
|
||||||
'setBreakpoint (sb)',
|
'setBreakpoint (sb)',
|
||||||
'clearBreakpoint (cb)',
|
'clearBreakpoint (cb)'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'watch',
|
'watch',
|
||||||
@ -799,7 +799,7 @@ function Interface(stdin, stdout, args) {
|
|||||||
self.resume();
|
self.resume();
|
||||||
});
|
});
|
||||||
}, 10);
|
}, 10);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
// Stream control
|
// Stream control
|
||||||
@ -1572,7 +1572,7 @@ Interface.prototype.trySpawn = function(cb) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('close', function() {
|
client.on('close', function() {
|
||||||
self.pause()
|
self.pause();
|
||||||
self.print('program terminated');
|
self.print('program terminated');
|
||||||
self.resume();
|
self.resume();
|
||||||
self.client = null;
|
self.client = null;
|
||||||
|
@ -122,7 +122,7 @@ assert.fail = fail;
|
|||||||
|
|
||||||
function ok(value, message) {
|
function ok(value, message) {
|
||||||
if (!!!value) fail(value, true, message, '==', assert.ok);
|
if (!!!value) fail(value, true, message, '==', assert.ok);
|
||||||
};
|
}
|
||||||
assert.ok = ok;
|
assert.ok = ok;
|
||||||
|
|
||||||
// 5. The equality assertion tests shallow, coercive equality with
|
// 5. The equality assertion tests shallow, coercive equality with
|
||||||
|
@ -272,7 +272,7 @@ function setStreamOption(name, index, options) {
|
|||||||
if (options.customFds[index] === index) {
|
if (options.customFds[index] === index) {
|
||||||
options[name] = null;
|
options[name] = null;
|
||||||
} else {
|
} else {
|
||||||
throw new Error("customFds not yet supported");
|
throw new Error('customFds not yet supported');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options[name] = createPipe();
|
options[name] = createPipe();
|
||||||
@ -283,9 +283,9 @@ function setStreamOption(name, index, options) {
|
|||||||
ChildProcess.prototype.spawn = function(options) {
|
ChildProcess.prototype.spawn = function(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
setStreamOption("stdinStream", 0, options);
|
setStreamOption('stdinStream', 0, options);
|
||||||
setStreamOption("stdoutStream", 1, options);
|
setStreamOption('stdoutStream', 1, options);
|
||||||
setStreamOption("stderrStream", 2, options);
|
setStreamOption('stderrStream', 2, options);
|
||||||
|
|
||||||
var r = this._internal.spawn(options);
|
var r = this._internal.spawn(options);
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ ChildProcess.prototype.spawn = function(options) {
|
|||||||
|
|
||||||
this._internal.close();
|
this._internal.close();
|
||||||
this._internal = null;
|
this._internal = null;
|
||||||
throw errnoException("spawn", errno)
|
throw errnoException('spawn', errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pid = this._internal.pid;
|
this.pid = this._internal.pid;
|
||||||
|
@ -162,7 +162,7 @@ exports.createDiffieHellman = function(size_or_key, enc) {
|
|||||||
return new DiffieHellman(size_or_key, enc);
|
return new DiffieHellman(size_or_key, enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.pbkdf2 = PBKDF2;
|
exports.pbkdf2 = PBKDF2;
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ function toUnixTimestamp(time) {
|
|||||||
// convert to 123.456 UNIX timestamp
|
// convert to 123.456 UNIX timestamp
|
||||||
return time.getTime() / 1000;
|
return time.getTime() / 1000;
|
||||||
}
|
}
|
||||||
throw new Error("Cannot parse time: " + time);
|
throw new Error('Cannot parse time: ' + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exported for unit tests, not for public consumption
|
// exported for unit tests, not for public consumption
|
||||||
@ -569,7 +569,8 @@ fs.writeFile = function(path, data, encoding_, callback) {
|
|||||||
if (openErr) {
|
if (openErr) {
|
||||||
if (callback) callback(openErr);
|
if (callback) callback(openErr);
|
||||||
} else {
|
} else {
|
||||||
var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data, encoding);
|
var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data,
|
||||||
|
encoding);
|
||||||
writeAll(fd, buffer, 0, buffer.length, callback);
|
writeAll(fd, buffer, 0, buffer.length, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -621,7 +622,7 @@ FSWatcher.prototype.start = function(filename, persistent) {
|
|||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
this._handle.close();
|
this._handle.close();
|
||||||
throw errnoException(errno, "watch")
|
throw errnoException(errno, 'watch');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ Socket.prototype._writeOut = function(data, encoding, fd, cb) {
|
|||||||
|
|
||||||
this.bytesWritten += bytesWritten;
|
this.bytesWritten += bytesWritten;
|
||||||
|
|
||||||
debug('wrote ' + bytesWritten + ' bytes to socket.')
|
debug('wrote ' + bytesWritten + ' bytes to socket.');
|
||||||
debug('[fd, off, len] = ' + JSON.stringify([this.fd, off, len]));
|
debug('[fd, off, len] = ' + JSON.stringify([this.fd, off, len]));
|
||||||
|
|
||||||
timers.active(this);
|
timers.active(this);
|
||||||
@ -509,7 +509,6 @@ Socket.prototype._writeOut = function(data, encoding, fd, cb) {
|
|||||||
|
|
||||||
Socket.prototype._onBufferChange = function() {
|
Socket.prototype._onBufferChange = function() {
|
||||||
// Put DTrace hooks here.
|
// Put DTrace hooks here.
|
||||||
;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ Socket.prototype.connect = function(port /* [host], [cb] */) {
|
|||||||
connect(self, /*pipe_name=*/port);
|
connect(self, /*pipe_name=*/port);
|
||||||
|
|
||||||
} else if (typeof host == 'string') {
|
} else if (typeof host == 'string') {
|
||||||
debug("connect: find host " + host);
|
debug('connect: find host ' + host);
|
||||||
require('dns').lookup(host, function(err, ip, addressType) {
|
require('dns').lookup(host, function(err, ip, addressType) {
|
||||||
// It's possible we were destroyed while looking this up.
|
// It's possible we were destroyed while looking this up.
|
||||||
// XXX it would be great if we could cancel the promise returned by
|
// XXX it would be great if we could cancel the promise returned by
|
||||||
@ -510,7 +510,7 @@ Socket.prototype.connect = function(port /* [host], [cb] */) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
debug("connect: missing host");
|
debug('connect: missing host');
|
||||||
connect(self, '127.0.0.1', port, 4);
|
connect(self, '127.0.0.1', port, 4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -526,7 +526,7 @@ function afterConnect(status, handle, req) {
|
|||||||
|
|
||||||
assert.equal(handle, self._handle);
|
assert.equal(handle, self._handle);
|
||||||
|
|
||||||
debug("afterConnect");
|
debug('afterConnect');
|
||||||
|
|
||||||
assert.ok(self._connecting);
|
assert.ok(self._connecting);
|
||||||
self._connecting = false;
|
self._connecting = false;
|
||||||
@ -553,7 +553,7 @@ function afterConnect(status, handle, req) {
|
|||||||
self.end();
|
self.end();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self._connectQueueCleanUp()
|
self._connectQueueCleanUp();
|
||||||
self.destroy(errnoException(errno, 'connect'));
|
self.destroy(errnoException(errno, 'connect'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ function listen(self, address, port, addressType) {
|
|||||||
self._handle.onconnection = onconnection;
|
self._handle.onconnection = onconnection;
|
||||||
|
|
||||||
if (address || port) {
|
if (address || port) {
|
||||||
debug("bind to " + address);
|
debug('bind to ' + address);
|
||||||
if (addressType == 6) {
|
if (addressType == 6) {
|
||||||
r = self._handle.bind6(address, port);
|
r = self._handle.bind6(address, port);
|
||||||
} else {
|
} else {
|
||||||
@ -693,7 +693,7 @@ function onconnection(clientHandle) {
|
|||||||
var self = handle.socket;
|
var self = handle.socket;
|
||||||
var peername;
|
var peername;
|
||||||
|
|
||||||
debug("onconnection");
|
debug('onconnection');
|
||||||
|
|
||||||
if (!clientHandle) {
|
if (!clientHandle) {
|
||||||
self.emit('error', errnoException(errno, 'accept'));
|
self.emit('error', errnoException(errno, 'accept'));
|
||||||
@ -778,12 +778,13 @@ exports.isIP = function(input) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 4;
|
return 4;
|
||||||
} else if (/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/.test(input)) {
|
} else if (/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/.test(
|
||||||
|
input)) {
|
||||||
return 6;
|
return 6;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.isIPv4 = function(input) {
|
exports.isIPv4 = function(input) {
|
||||||
|
@ -76,7 +76,7 @@ if (isWindows) {
|
|||||||
basename = result2[2] || '',
|
basename = result2[2] || '',
|
||||||
ext = result2[3] || '';
|
ext = result2[3] || '';
|
||||||
return [device, dir, basename, ext];
|
return [device, dir, basename, ext];
|
||||||
}
|
};
|
||||||
|
|
||||||
// path.resolve([from ...], to)
|
// path.resolve([from ...], to)
|
||||||
// windows version
|
// windows version
|
||||||
|
@ -292,7 +292,8 @@ Interface.prototype._tabComplete = function() {
|
|||||||
var item = group[idx];
|
var item = group[idx];
|
||||||
self.output.write(item);
|
self.output.write(item);
|
||||||
if (col < maxColumns - 1) {
|
if (col < maxColumns - 1) {
|
||||||
for (var s = 0, itemLen = item.length; s < width - itemLen; s++) {
|
for (var s = 0, itemLen = item.length; s < width - itemLen;
|
||||||
|
s++) {
|
||||||
self.output.write(' ');
|
self.output.write(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
lib/repl.js
13
lib/repl.js
@ -110,7 +110,8 @@ function REPLServer(prompt, stream, eval) {
|
|||||||
this.commands = {};
|
this.commands = {};
|
||||||
defineDefaultCommands(this);
|
defineDefaultCommands(this);
|
||||||
|
|
||||||
if (rli.enabled && !exports.disableColors && exports.writer === util.inspect) {
|
if (rli.enabled && !exports.disableColors &&
|
||||||
|
exports.writer === util.inspect) {
|
||||||
// Turn on ANSI coloring.
|
// Turn on ANSI coloring.
|
||||||
exports.writer = function(obj, showHidden, depth) {
|
exports.writer = function(obj, showHidden, depth) {
|
||||||
return util.inspect(obj, showHidden, depth, true);
|
return util.inspect(obj, showHidden, depth, true);
|
||||||
@ -447,11 +448,11 @@ REPLServer.prototype.complete = function(line, callback) {
|
|||||||
// they just get in the way.
|
// they just get in the way.
|
||||||
if (filter) {
|
if (filter) {
|
||||||
completionGroups.push(['break', 'case', 'catch', 'const',
|
completionGroups.push(['break', 'case', 'catch', 'const',
|
||||||
'continue', 'debugger', 'default', 'delete', 'do', 'else', 'export',
|
'continue', 'debugger', 'default', 'delete', 'do', 'else',
|
||||||
'false', 'finally', 'for', 'function', 'if', 'import', 'in',
|
'export', 'false', 'finally', 'for', 'function', 'if',
|
||||||
'instanceof', 'let', 'new', 'null', 'return', 'switch', 'this',
|
'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
|
||||||
'throw', 'true', 'try', 'typeof', 'undefined', 'var', 'void',
|
'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined',
|
||||||
'while', 'with', 'yield']);
|
'var', 'void', 'while', 'with', 'yield']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ exports.isatty = function(fd) {
|
|||||||
|
|
||||||
|
|
||||||
exports.setRawMode = function(flag) {
|
exports.setRawMode = function(flag) {
|
||||||
assert.ok(stdinHandle, "stdin must be initialized before calling setRawMode");
|
assert.ok(stdinHandle, 'stdin must be initialized before calling setRawMode');
|
||||||
stdinHandle.setRawMode(flag);
|
stdinHandle.setRawMode(flag);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ exports.getWindowSize = function() {
|
|||||||
|
|
||||||
|
|
||||||
exports.setWindowSize = function() {
|
exports.setWindowSize = function() {
|
||||||
throw new Error("implement me");
|
throw new Error('implement me');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ exports.format = function(f) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.print = function() {
|
exports.print = function() {
|
||||||
@ -98,7 +98,7 @@ function inspect(obj, showHidden, depth, colors) {
|
|||||||
var ctx = {
|
var ctx = {
|
||||||
showHidden: showHidden,
|
showHidden: showHidden,
|
||||||
seen: [],
|
seen: [],
|
||||||
stylize: colors ? stylizeWithColor : stylizeNoColor,
|
stylize: colors ? stylizeWithColor : stylizeNoColor
|
||||||
};
|
};
|
||||||
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
||||||
}
|
}
|
||||||
|
14
src/node.js
14
src/node.js
@ -227,7 +227,7 @@
|
|||||||
case 'TTY':
|
case 'TTY':
|
||||||
var tty = NativeModule.require('tty');
|
var tty = NativeModule.require('tty');
|
||||||
stdout = new tty.WriteStream(fd);
|
stdout = new tty.WriteStream(fd);
|
||||||
stdout._type = "tty";
|
stdout._type = 'tty';
|
||||||
|
|
||||||
// Hack to have stdout not keep the event loop alive.
|
// Hack to have stdout not keep the event loop alive.
|
||||||
// See https://github.com/joyent/node/issues/1726
|
// See https://github.com/joyent/node/issues/1726
|
||||||
@ -237,7 +237,7 @@
|
|||||||
case 'FILE':
|
case 'FILE':
|
||||||
var fs = NativeModule.require('fs');
|
var fs = NativeModule.require('fs');
|
||||||
stdout = new fs.WriteStream(null, {fd: fd});
|
stdout = new fs.WriteStream(null, {fd: fd});
|
||||||
stdout._type = "fs";
|
stdout._type = 'fs';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PIPE':
|
case 'PIPE':
|
||||||
@ -249,7 +249,7 @@
|
|||||||
// we'll just add this hack and set the `readable` member to false.
|
// we'll just add this hack and set the `readable` member to false.
|
||||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||||
stdout.readable = false;
|
stdout.readable = false;
|
||||||
stdout._type = "pipe";
|
stdout._type = 'pipe';
|
||||||
|
|
||||||
// FIXME Hack to have stdout not keep the event loop alive.
|
// FIXME Hack to have stdout not keep the event loop alive.
|
||||||
// See https://github.com/joyent/node/issues/1726
|
// See https://github.com/joyent/node/issues/1726
|
||||||
@ -258,7 +258,7 @@
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// Probably an error on in uv_guess_handle()
|
// Probably an error on in uv_guess_handle()
|
||||||
throw new Error("Implement me. Unknown stdout file type!");
|
throw new Error('Implement me. Unknown stdout file type!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// For supporting legacy API we put the FD here.
|
// For supporting legacy API we put the FD here.
|
||||||
@ -301,7 +301,7 @@
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// Probably an error on in uv_guess_handle()
|
// Probably an error on in uv_guess_handle()
|
||||||
throw new Error("Implement me. Unknown stdin file type!");
|
throw new Error('Implement me. Unknown stdin file type!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// For supporting legacy API we put the FD here.
|
// For supporting legacy API we put the FD here.
|
||||||
@ -403,7 +403,7 @@
|
|||||||
'mixin': 'process.mixin() has been removed.',
|
'mixin': 'process.mixin() has been removed.',
|
||||||
'createChildProcess': 'childProcess API has changed. See doc/api.txt.',
|
'createChildProcess': 'childProcess API has changed. See doc/api.txt.',
|
||||||
'inherits': 'process.inherits() has moved to sys.inherits.',
|
'inherits': 'process.inherits() has moved to sys.inherits.',
|
||||||
'_byteLength': 'process._byteLength() has moved to Buffer.byteLength',
|
'_byteLength': 'process._byteLength() has moved to Buffer.byteLength'
|
||||||
};
|
};
|
||||||
|
|
||||||
startup.removedMethods = function() {
|
startup.removedMethods = function() {
|
||||||
@ -498,7 +498,7 @@
|
|||||||
throw new Error('No such native module ' + id);
|
throw new Error('No such native module ' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.moduleLoadList.push("NativeModule " + id);
|
process.moduleLoadList.push('NativeModule ' + id);
|
||||||
|
|
||||||
var nativeModule = new NativeModule(id);
|
var nativeModule = new NativeModule(id);
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ exports.ddCommand = function(filename, kilobytes) {
|
|||||||
exports.spawnPwd = function(options) {
|
exports.spawnPwd = function(options) {
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
|
|
||||||
if (process.platform == "win32") {
|
if (process.platform == 'win32') {
|
||||||
return spawn('cmd.exe', ['/c', 'cd'], options);
|
return spawn('cmd.exe', ['/c', 'cd'], options);
|
||||||
} else {
|
} else {
|
||||||
return spawn('pwd', [], options);
|
return spawn('pwd', [], options);
|
||||||
|
@ -31,9 +31,7 @@ req.on('error', function(e) {
|
|||||||
function loadDom() {
|
function loadDom() {
|
||||||
// Do a lot of computation to stall the process.
|
// Do a lot of computation to stall the process.
|
||||||
// In the meantime the socket will be disconnected.
|
// In the meantime the socket will be disconnected.
|
||||||
for (var i = 0; i < 1e8; i++) {
|
for (var i = 0; i < 1e8; i++);
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Dom loaded.');
|
console.log('Dom loaded.');
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,16 @@
|
|||||||
// libuv-broken
|
// libuv-broken
|
||||||
|
|
||||||
|
|
||||||
var assert = require("assert");
|
var assert = require('assert');
|
||||||
var spawn = require("child_process").spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
var myUid = process.getuid();
|
var myUid = process.getuid();
|
||||||
var myGid = process.getgid();
|
var myGid = process.getgid();
|
||||||
|
|
||||||
if (myUid != 0) {
|
if (myUid != 0) {
|
||||||
console.error('must be run as root, otherwise the gid/uid setting will fail.');
|
console.error('must be run as root, otherwise the gid/uid setting will' +
|
||||||
|
' fail.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +41,8 @@ var passwd = fs.readFileSync('/etc/passwd', 'utf8');
|
|||||||
passwd = passwd.trim().split(/\n/);
|
passwd = passwd.trim().split(/\n/);
|
||||||
|
|
||||||
for (var i = 0, l = passwd.length; i < l; i++) {
|
for (var i = 0, l = passwd.length; i < l; i++) {
|
||||||
if (passwd[i].charAt(0) === "#") continue;
|
if (passwd[i].charAt(0) === '#') continue;
|
||||||
passwd[i] = passwd[i].split(":");
|
passwd[i] = passwd[i].split(':');
|
||||||
var otherName = passwd[i][0];
|
var otherName = passwd[i][0];
|
||||||
var otherUid = +passwd[i][2];
|
var otherUid = +passwd[i][2];
|
||||||
var otherGid = +passwd[i][3];
|
var otherGid = +passwd[i][3];
|
||||||
@ -64,18 +65,18 @@ whoNumber.stdout.on('data', onData);
|
|||||||
whoName.stdout.on('data', onData);
|
whoName.stdout.on('data', onData);
|
||||||
function onData(c) { this.buf += c; }
|
function onData(c) { this.buf += c; }
|
||||||
|
|
||||||
whoNumber.on("exit", onExit);
|
whoNumber.on('exit', onExit);
|
||||||
whoName.on("exit", onExit);
|
whoName.on('exit', onExit);
|
||||||
|
|
||||||
function onExit(code) {
|
function onExit(code) {
|
||||||
var buf = this.stdout.buf;
|
var buf = this.stdout.buf;
|
||||||
console.log(buf);
|
console.log(buf);
|
||||||
var expr = new RegExp("^(byName|byNumber):uid=" +
|
var expr = new RegExp('^(byName|byNumber):uid=' +
|
||||||
otherUid +
|
otherUid +
|
||||||
"\\(" +
|
'\\(' +
|
||||||
otherName +
|
otherName +
|
||||||
"\\) gid=" +
|
'\\) gid=' +
|
||||||
otherGid +
|
otherGid +
|
||||||
"\\(");
|
'\\(');
|
||||||
assert.ok(buf.match(expr), "uid and gid should match " + otherName);
|
assert.ok(buf.match(expr), 'uid and gid should match ' + otherName);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ var reqEndCount = 0;
|
|||||||
|
|
||||||
var server = http.Server(function(req, res) {
|
var server = http.Server(function(req, res) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
|
|
||||||
var buffer = '';
|
var buffer = '';
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ var responses = 0;
|
|||||||
var N = 10;
|
var N = 10;
|
||||||
var M = 10;
|
var M = 10;
|
||||||
|
|
||||||
var body = ''
|
var body = '';
|
||||||
for (var i = 0; i < 1000; i++) {
|
for (var i = 0; i < 1000; i++) {
|
||||||
body += 'hello world';
|
body += 'hello world';
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@
|
|||||||
|
|
||||||
// This must be run as root.
|
// This must be run as root.
|
||||||
|
|
||||||
var http = require("http"),
|
var http = require('http'),
|
||||||
https = require("https"),
|
https = require('https'),
|
||||||
PORT = 80,
|
PORT = 80,
|
||||||
SSLPORT = 443,
|
SSLPORT = 443,
|
||||||
assert = require("assert"),
|
assert = require('assert'),
|
||||||
hostExpect = "localhost",
|
hostExpect = 'localhost',
|
||||||
fs = require("fs"),
|
fs = require('fs'),
|
||||||
path = require("path"),
|
path = require('path'),
|
||||||
fixtures = path.resolve(__dirname, "../fixtures/keys"),
|
fixtures = path.resolve(__dirname, '../fixtures/keys'),
|
||||||
options = {
|
options = {
|
||||||
key: fs.readFileSync(fixtures + '/agent1-key.pem'),
|
key: fs.readFileSync(fixtures + '/agent1-key.pem'),
|
||||||
cert: fs.readFileSync(fixtures + '/agent1-cert.pem')
|
cert: fs.readFileSync(fixtures + '/agent1-cert.pem')
|
||||||
@ -42,7 +42,7 @@ http.createServer(function (req, res) {
|
|||||||
console.error(req.headers);
|
console.error(req.headers);
|
||||||
assert.equal(req.headers.host, hostExpect);
|
assert.equal(req.headers.host, hostExpect);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("ok");
|
res.end('ok');
|
||||||
this.close();
|
this.close();
|
||||||
}).listen(PORT);
|
}).listen(PORT);
|
||||||
|
|
||||||
@ -50,18 +50,18 @@ https.createServer(options, function (req, res) {
|
|||||||
console.error(req.headers);
|
console.error(req.headers);
|
||||||
assert.equal(req.headers.host, hostExpect);
|
assert.equal(req.headers.host, hostExpect);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("ok");
|
res.end('ok');
|
||||||
this.close();
|
this.close();
|
||||||
}).listen(SSLPORT);
|
}).listen(SSLPORT);
|
||||||
|
|
||||||
http
|
http
|
||||||
.get({ host: "localhost",
|
.get({ host: 'localhost',
|
||||||
port: PORT,
|
port: PORT,
|
||||||
headers: { "x-port": PORT } })
|
headers: { 'x-port': PORT } })
|
||||||
.on("response", function(res) {});
|
.on('response', function(res) {});
|
||||||
|
|
||||||
https
|
https
|
||||||
.get({ host: "localhost",
|
.get({ host: 'localhost',
|
||||||
port: SSLPORT,
|
port: SSLPORT,
|
||||||
headers: { "x-port": SSLPORT } })
|
headers: { 'x-port': SSLPORT } })
|
||||||
.on("response", function(res) {});
|
.on('response', function(res) {});
|
||||||
|
@ -36,7 +36,7 @@ for(var i = 0; i < 10; ++i)
|
|||||||
{
|
{
|
||||||
host: 'www.google.com',
|
host: 'www.google.com',
|
||||||
path: '/accounts/o8/id',
|
path: '/accounts/o8/id',
|
||||||
port: 443,
|
port: 443
|
||||||
}, function(res)
|
}, function(res)
|
||||||
{
|
{
|
||||||
var data = '';
|
var data = '';
|
||||||
|
@ -30,13 +30,13 @@ var fs = require('fs');
|
|||||||
// most servers don't require certificates
|
// most servers don't require certificates
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var s = tls.connect(443, "joyent.com", options, function() {
|
var s = tls.connect(443, 'joyent.com', options, function() {
|
||||||
if (!s.authorized) {
|
if (!s.authorized) {
|
||||||
console.error("CONNECTED: " + s.authorizationError);
|
console.error('CONNECTED: ' + s.authorizationError);
|
||||||
s.destroy();
|
s.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
2
test/fixtures/GH-892-request.js
vendored
2
test/fixtures/GH-892-request.js
vendored
@ -38,7 +38,7 @@ var options = {
|
|||||||
var req = https.request(options, function(res) {
|
var req = https.request(options, function(res) {
|
||||||
assert.equal(200, res.statusCode);
|
assert.equal(200, res.statusCode);
|
||||||
gotResponse = true;
|
gotResponse = true;
|
||||||
console.error("DONE");
|
console.error('DONE');
|
||||||
});
|
});
|
||||||
|
|
||||||
req.end(new Buffer(bytesExpected));
|
req.end(new Buffer(bytesExpected));
|
||||||
|
4
test/fixtures/breakpoints.js
vendored
4
test/fixtures/breakpoints.js
vendored
@ -6,10 +6,10 @@ function a(x) {
|
|||||||
while (--i != 0);
|
while (--i != 0);
|
||||||
debugger;
|
debugger;
|
||||||
return i;
|
return i;
|
||||||
};
|
}
|
||||||
function b() {
|
function b() {
|
||||||
return ['hello', 'world'].join(' ');
|
return ['hello', 'world'].join(' ');
|
||||||
};
|
}
|
||||||
a();
|
a();
|
||||||
a(1);
|
a(1);
|
||||||
b();
|
b();
|
||||||
|
2
test/fixtures/child-process-channel.js
vendored
2
test/fixtures/child-process-channel.js
vendored
@ -1,6 +1,6 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
console.log("NODE_CHANNEL_FD", process.env.NODE_CHANNEL_FD);
|
console.log('NODE_CHANNEL_FD', process.env.NODE_CHANNEL_FD);
|
||||||
assert.ok(process.env.NODE_CHANNEL_FD);
|
assert.ok(process.env.NODE_CHANNEL_FD);
|
||||||
|
|
||||||
var fd = parseInt(process.env.NODE_CHANNEL_FD);
|
var fd = parseInt(process.env.NODE_CHANNEL_FD);
|
||||||
|
@ -19,4 +19,4 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
exports.ok = "ok"
|
exports.ok = 'ok';
|
||||||
|
@ -19,4 +19,4 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
exports.ok = "ok"
|
exports.ok = 'ok';
|
||||||
|
1
test/fixtures/test-init-index/index.js
vendored
1
test/fixtures/test-init-index/index.js
vendored
@ -22,3 +22,4 @@
|
|||||||
(function() {
|
(function() {
|
||||||
require('util').print('Loaded successfully!');
|
require('util').print('Loaded successfully!');
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
1
test/fixtures/test-init-native/fs.js
vendored
1
test/fixtures/test-init-native/fs.js
vendored
@ -25,3 +25,4 @@
|
|||||||
require('util').print('fs loaded successfully');
|
require('util').print('fs loaded successfully');
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
var assert = require('assert');
|
var assert = require('assert'),
|
||||||
dns = require('dns'),
|
dns = require('dns'),
|
||||||
net = require('net_uv');
|
net = require('net_uv'),
|
||||||
isIP = net.isIP,
|
isIP = net.isIP,
|
||||||
isIPv4 = net.isIPv4,
|
isIPv4 = net.isIPv4,
|
||||||
isIPv6 = net.isIPv6,
|
isIPv6 = net.isIPv6,
|
||||||
@ -315,7 +315,7 @@ TEST(function test_lookup_ipv6_implicit(done) {
|
|||||||
TEST(function test_lookup_failure(done) {
|
TEST(function test_lookup_failure(done) {
|
||||||
var req = dns.lookup('does.not.exist', 4, function(err, ip, family) {
|
var req = dns.lookup('does.not.exist', 4, function(err, ip, family) {
|
||||||
assert.ok(err instanceof Error);
|
assert.ok(err instanceof Error);
|
||||||
assert.strictEqual(err.errno, dns.NOTFOUND)
|
assert.strictEqual(err.errno, dns.NOTFOUND);
|
||||||
uv && assert.strictEqual(err.errno, 'ENOTFOUND');
|
uv && assert.strictEqual(err.errno, 'ENOTFOUND');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
@ -28,6 +28,6 @@ var assert = require('assert');
|
|||||||
common.error('before');
|
common.error('before');
|
||||||
|
|
||||||
// custom error throwing
|
// custom error throwing
|
||||||
throw { name: 'MyCustomError', message: 'This is a custom message' };
|
throw { name: 'MyCustomError', message: 'This is a custom message' }
|
||||||
|
|
||||||
common.error('after');
|
common.error('after');
|
||||||
|
@ -28,6 +28,6 @@ var assert = require('assert');
|
|||||||
common.error('before');
|
common.error('before');
|
||||||
|
|
||||||
// custom error throwing
|
// custom error throwing
|
||||||
throw { foo : 'bar' };
|
throw { foo: 'bar' }
|
||||||
|
|
||||||
common.error('after');
|
common.error('after');
|
||||||
|
@ -36,7 +36,7 @@ server.on('request', function(req, res) {
|
|||||||
req.on('end', function() {
|
req.on('end', function() {
|
||||||
connections--;
|
connections--;
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("done\n");
|
res.end('done\n');
|
||||||
if (connections == 0) {
|
if (connections == 0) {
|
||||||
server.close();
|
server.close();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ var gotResEnd = false;
|
|||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
https.get({ port: common.PORT }, function(res) {
|
https.get({ port: common.PORT }, function(res) {
|
||||||
console.log("response!");
|
console.log('response!');
|
||||||
|
|
||||||
res.on('data', function(d) {
|
res.on('data', function(d) {
|
||||||
process.stdout.write('.');
|
process.stdout.write('.');
|
||||||
@ -67,8 +67,8 @@ server.listen(common.PORT, function () {
|
|||||||
|
|
||||||
res.on('end', function(d) {
|
res.on('end', function(d) {
|
||||||
process.stdout.write('\n');
|
process.stdout.write('\n');
|
||||||
console.log("expected: ", body.length);
|
console.log('expected: ', body.length);
|
||||||
console.log(" got: ", count);
|
console.log(' got: ', count);
|
||||||
server.close();
|
server.close();
|
||||||
gotResEnd = true;
|
gotResEnd = true;
|
||||||
});
|
});
|
||||||
|
@ -28,11 +28,11 @@ var N = 500000;
|
|||||||
|
|
||||||
var server = net.Server(function(socket) {
|
var server = net.Server(function(socket) {
|
||||||
socket.on('data', function(d) {
|
socket.on('data', function(d) {
|
||||||
console.error("got %d bytes", d.length);
|
console.error('got %d bytes', d.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('end', function() {
|
socket.on('end', function() {
|
||||||
console.error("end");
|
console.error('end');
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
@ -43,7 +43,7 @@ server.listen(common.PORT, function() {
|
|||||||
|
|
||||||
client.on('connect', function() {
|
client.on('connect', function() {
|
||||||
for (var i = 0; i < N; i++) {
|
for (var i = 0; i < N; i++) {
|
||||||
client.write("hello world", function() {
|
client.write('hello world', function() {
|
||||||
cbcount++;
|
cbcount++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ var assert = require('assert');
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
t = Date.now() - t;
|
t = Date.now() - t;
|
||||||
STOP = 1;
|
STOP = 1;
|
||||||
console.log(["ctr: ",ctr, ", t:", t, "ms -> ", (ctr/t).toFixed(2), "KHz"].join(''));
|
console.log(['ctr: ', ctr, ', t:', t, 'ms -> ', (ctr / t).toFixed(2), 'KHz']
|
||||||
|
.join(''));
|
||||||
assert.ok(ctr > 1000);
|
assert.ok(ctr > 1000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
@ -197,14 +197,14 @@ threw = false;
|
|||||||
try {
|
try {
|
||||||
assert.throws(
|
assert.throws(
|
||||||
function() {
|
function() {
|
||||||
throw {};
|
throw {}
|
||||||
},
|
},
|
||||||
Array
|
Array
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
threw = true;
|
threw = true;
|
||||||
}
|
}
|
||||||
assert.ok(threw, "wrong constructor validation");
|
assert.ok(threw, 'wrong constructor validation');
|
||||||
|
|
||||||
// use a RegExp to validate error message
|
// use a RegExp to validate error message
|
||||||
a.throws(makeBlock(thrower, TypeError), /test/);
|
a.throws(makeBlock(thrower, TypeError), /test/);
|
||||||
|
@ -260,7 +260,8 @@ var f = new Buffer([0, 0, 0, 0, 0]);
|
|||||||
assert.equal(f.length, 5);
|
assert.equal(f.length, 5);
|
||||||
var size = f.write('あいうえお', 'ucs2');
|
var size = f.write('あいうえお', 'ucs2');
|
||||||
console.error('bytes written to buffer: %d (should be 4)', size);
|
console.error('bytes written to buffer: %d (should be 4)', size);
|
||||||
console.error('chars written to buffer: %d (should be 2)', Buffer._charsWritten);
|
console.error('chars written to buffer: %d (should be 2)',
|
||||||
|
Buffer._charsWritten);
|
||||||
assert.equal(size, 4);
|
assert.equal(size, 4);
|
||||||
assert.equal(Buffer._charsWritten, 2);
|
assert.equal(Buffer._charsWritten, 2);
|
||||||
assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00]));
|
assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00]));
|
||||||
@ -503,18 +504,18 @@ function buildSlowBuffer (data) {
|
|||||||
buffer[k] = v;
|
buffer[k] = v;
|
||||||
});
|
});
|
||||||
return buffer;
|
return buffer;
|
||||||
};
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var x = buildSlowBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]);
|
var x = buildSlowBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]);
|
||||||
|
|
||||||
console.log(x.inspect())
|
console.log(x.inspect());
|
||||||
assert.equal('<SlowBuffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
|
assert.equal('<SlowBuffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
|
||||||
|
|
||||||
var z = x.slice(4);
|
var z = x.slice(4);
|
||||||
console.log(z.inspect())
|
console.log(z.inspect());
|
||||||
console.log(z.length)
|
console.log(z.length);
|
||||||
assert.equal(5, z.length);
|
assert.equal(5, z.length);
|
||||||
assert.equal(0x6f, z[0]);
|
assert.equal(0x6f, z[0]);
|
||||||
assert.equal(0xa3, z[1]);
|
assert.equal(0xa3, z[1]);
|
||||||
@ -523,41 +524,41 @@ assert.equal(0x61, z[3]);
|
|||||||
assert.equal(0x72, z[4]);
|
assert.equal(0x72, z[4]);
|
||||||
|
|
||||||
var z = x.slice(0);
|
var z = x.slice(0);
|
||||||
console.log(z.inspect())
|
console.log(z.inspect());
|
||||||
console.log(z.length)
|
console.log(z.length);
|
||||||
assert.equal(z.length, x.length);
|
assert.equal(z.length, x.length);
|
||||||
|
|
||||||
var z = x.slice(0, 4);
|
var z = x.slice(0, 4);
|
||||||
console.log(z.inspect())
|
console.log(z.inspect());
|
||||||
console.log(z.length)
|
console.log(z.length);
|
||||||
assert.equal(4, z.length);
|
assert.equal(4, z.length);
|
||||||
assert.equal(0x81, z[0]);
|
assert.equal(0x81, z[0]);
|
||||||
assert.equal(0xa3, z[1]);
|
assert.equal(0xa3, z[1]);
|
||||||
|
|
||||||
var z = x.slice(0, 9);
|
var z = x.slice(0, 9);
|
||||||
console.log(z.inspect())
|
console.log(z.inspect());
|
||||||
console.log(z.length)
|
console.log(z.length);
|
||||||
assert.equal(9, z.length);
|
assert.equal(9, z.length);
|
||||||
|
|
||||||
var z = x.slice(1, 4);
|
var z = x.slice(1, 4);
|
||||||
console.log(z.inspect())
|
console.log(z.inspect());
|
||||||
console.log(z.length)
|
console.log(z.length);
|
||||||
assert.equal(3, z.length);
|
assert.equal(3, z.length);
|
||||||
assert.equal(0xa3, z[0]);
|
assert.equal(0xa3, z[0]);
|
||||||
|
|
||||||
var z = x.slice(2, 4);
|
var z = x.slice(2, 4);
|
||||||
console.log(z.inspect())
|
console.log(z.inspect());
|
||||||
console.log(z.length)
|
console.log(z.length);
|
||||||
assert.equal(2, z.length);
|
assert.equal(2, z.length);
|
||||||
assert.equal(0x66, z[0]);
|
assert.equal(0x66, z[0]);
|
||||||
assert.equal(0x6f, z[1]);
|
assert.equal(0x6f, z[1]);
|
||||||
|
|
||||||
assert.equal(0, Buffer('hello').slice(0, 0).length)
|
assert.equal(0, Buffer('hello').slice(0, 0).length);
|
||||||
|
|
||||||
b = new Buffer(50);
|
b = new Buffer(50);
|
||||||
b.fill("h");
|
b.fill('h');
|
||||||
for (var i = 0; i < b.length; i++) {
|
for (var i = 0; i < b.length; i++) {
|
||||||
assert.equal("h".charCodeAt(0), b[i]);
|
assert.equal('h'.charCodeAt(0), b[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
b.fill(0);
|
b.fill(0);
|
||||||
@ -577,13 +578,13 @@ assert.equal(b.toString('ucs2'), 'あいうえお');
|
|||||||
// Binary encoding should write only one byte per character.
|
// Binary encoding should write only one byte per character.
|
||||||
var b = Buffer([0xde, 0xad, 0xbe, 0xef]);
|
var b = Buffer([0xde, 0xad, 0xbe, 0xef]);
|
||||||
var s = String.fromCharCode(0xffff);
|
var s = String.fromCharCode(0xffff);
|
||||||
b.write(s, 0, 'binary')
|
b.write(s, 0, 'binary');
|
||||||
assert.equal(0xff, b[0]);
|
assert.equal(0xff, b[0]);
|
||||||
assert.equal(0xad, b[1]);
|
assert.equal(0xad, b[1]);
|
||||||
assert.equal(0xbe, b[2]);
|
assert.equal(0xbe, b[2]);
|
||||||
assert.equal(0xef, b[3]);
|
assert.equal(0xef, b[3]);
|
||||||
s = String.fromCharCode(0xaaee);
|
s = String.fromCharCode(0xaaee);
|
||||||
b.write(s, 0, 'binary')
|
b.write(s, 0, 'binary');
|
||||||
assert.equal(0xee, b[0]);
|
assert.equal(0xee, b[0]);
|
||||||
assert.equal(0xad, b[1]);
|
assert.equal(0xad, b[1]);
|
||||||
assert.equal(0xbe, b[2]);
|
assert.equal(0xbe, b[2]);
|
||||||
@ -592,7 +593,7 @@ assert.equal(0xef, b[3]);
|
|||||||
|
|
||||||
// This should not segfault the program.
|
// This should not segfault the program.
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
new Buffer('"pong"', 0, 6, 8031, '127.0.0.1')
|
new Buffer('"pong"', 0, 6, 8031, '127.0.0.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
// #1210 Test UTF-8 string includes null character
|
// #1210 Test UTF-8 string includes null character
|
||||||
@ -697,8 +698,8 @@ assert.equal(Buffer(-1).length, 0);
|
|||||||
assert.equal(Buffer(NaN).length, 0);
|
assert.equal(Buffer(NaN).length, 0);
|
||||||
assert.equal(Buffer(3.3).length, 4);
|
assert.equal(Buffer(3.3).length, 4);
|
||||||
assert.equal(Buffer({length: 3.3}).length, 4);
|
assert.equal(Buffer({length: 3.3}).length, 4);
|
||||||
assert.equal(Buffer({length:"BAM"}).length, 0);
|
assert.equal(Buffer({length: 'BAM'}).length, 0);
|
||||||
|
|
||||||
// Make sure that strings are not coerced to numbers.
|
// Make sure that strings are not coerced to numbers.
|
||||||
assert.equal(Buffer("99").length, 2);
|
assert.equal(Buffer('99').length, 2);
|
||||||
assert.equal(Buffer("13.37").length, 5);
|
assert.equal(Buffer('13.37').length, 5);
|
||||||
|
@ -9,7 +9,7 @@ var child = spawn(process.execPath, [ sub ], {
|
|||||||
wantChannel: true
|
wantChannel: true
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("fds", child.fds);
|
console.log('fds', child.fds);
|
||||||
|
|
||||||
assert.ok(child.fds.length == 4);
|
assert.ok(child.fds.length == 4);
|
||||||
assert.ok(child.fds[3] >= 0);
|
assert.ok(child.fds[3] >= 0);
|
||||||
|
@ -53,7 +53,7 @@ function testCwd(options, forCode, forData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assume these exist, and 'pwd' gives us the right directory back
|
// Assume these exist, and 'pwd' gives us the right directory back
|
||||||
if (process.platform == "win32") {
|
if (process.platform == 'win32') {
|
||||||
testCwd({cwd: process.env.windir}, 0, process.env.windir);
|
testCwd({cwd: process.env.windir}, 0, process.env.windir);
|
||||||
testCwd({cwd: 'c:\\'}, 0, 'c:\\');
|
testCwd({cwd: 'c:\\'}, 0, 'c:\\');
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +47,7 @@ var echo = spawn('echo', ['hello\nnode\nand\nworld\n']),
|
|||||||
|
|
||||||
// pipe echo | grep
|
// pipe echo | grep
|
||||||
echo.stdout.on('data', function(data) {
|
echo.stdout.on('data', function(data) {
|
||||||
console.error("grep stdin write " + data.length);
|
console.error('grep stdin write ' + data.length);
|
||||||
if (!grep.stdin.write(data)) {
|
if (!grep.stdin.write(data)) {
|
||||||
echo.stdout.pause();
|
echo.stdout.pause();
|
||||||
}
|
}
|
||||||
@ -63,22 +63,22 @@ echo.stdout.on('end', function(code) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
echo.on('exit', function() {
|
echo.on('exit', function() {
|
||||||
console.error("echo exit");
|
console.error('echo exit');
|
||||||
})
|
});
|
||||||
|
|
||||||
grep.on('exit', function() {
|
grep.on('exit', function() {
|
||||||
console.error("grep exit");
|
console.error('grep exit');
|
||||||
})
|
});
|
||||||
|
|
||||||
sed.on('exit', function() {
|
sed.on('exit', function() {
|
||||||
console.error("sed exit");
|
console.error('sed exit');
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// pipe grep | sed
|
// pipe grep | sed
|
||||||
grep.stdout.on('data', function(data) {
|
grep.stdout.on('data', function(data) {
|
||||||
console.error("grep stdout " + data.length);
|
console.error('grep stdout ' + data.length);
|
||||||
if (!sed.stdin.write(data)) {
|
if (!sed.stdin.write(data)) {
|
||||||
grep.stdout.pause();
|
grep.stdout.pause();
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ sed.stdin.on('drain', function(data) {
|
|||||||
|
|
||||||
// propagate end from grep to sed
|
// propagate end from grep to sed
|
||||||
grep.stdout.on('end', function(code) {
|
grep.stdout.on('end', function(code) {
|
||||||
console.error("grep stdout end");
|
console.error('grep stdout end');
|
||||||
sed.stdin.end();
|
sed.stdin.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ var env = {
|
|||||||
};
|
};
|
||||||
env.__proto__ = {
|
env.__proto__ = {
|
||||||
'FOO': 'BAR'
|
'FOO': 'BAR'
|
||||||
}
|
};
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
var child = spawn('cmd.exe', ['/c', 'set'], {env: env});
|
var child = spawn('cmd.exe', ['/c', 'set'], {env: env});
|
||||||
|
@ -55,7 +55,7 @@ child.stdout.addListener('data', function(chunk) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
process.addListener('exit', function() {
|
process.addListener('exit', function() {
|
||||||
console.log("response: ", response);
|
console.log('response: ', response);
|
||||||
assert.equal(1, success_count);
|
assert.equal(1, success_count);
|
||||||
assert.equal(0, error_count);
|
assert.equal(0, error_count);
|
||||||
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
|
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
|
||||||
|
@ -21,16 +21,16 @@
|
|||||||
|
|
||||||
var common = require('../common');
|
var common = require('../common');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var ch = require("child_process")
|
var ch = require('child_process');
|
||||||
|
|
||||||
var SIZE = 100000
|
var SIZE = 100000;
|
||||||
var childGone = false;
|
var childGone = false;
|
||||||
|
|
||||||
var cp = ch.spawn("python", ['-c', 'print ' + SIZE + ' * "C"'], {
|
var cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
|
||||||
customFds: [0, 1, 2]
|
customFds: [0, 1, 2]
|
||||||
});
|
});
|
||||||
|
|
||||||
cp.on("exit", function (code) {
|
cp.on('exit', function(code) {
|
||||||
childGone = true;
|
childGone = true;
|
||||||
assert.equal(0, code);
|
assert.equal(0, code);
|
||||||
});
|
});
|
||||||
|
@ -43,7 +43,7 @@ child.exec(nodejs + ' --eval 42',
|
|||||||
// assert that "42\n" is written to stderr
|
// assert that "42\n" is written to stderr
|
||||||
child.exec(nodejs + ' --eval "console.error(42)"',
|
child.exec(nodejs + ' --eval "console.error(42)"',
|
||||||
function(err, stdout, stderr) {
|
function(err, stdout, stderr) {
|
||||||
assert.equal(stderr, "42\n");
|
assert.equal(stderr, '42\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
// assert that module loading works
|
// assert that module loading works
|
||||||
|
@ -41,7 +41,7 @@ global.process.stdout.write = function(string) {
|
|||||||
console.log('foo');
|
console.log('foo');
|
||||||
console.log('foo', 'bar');
|
console.log('foo', 'bar');
|
||||||
console.log('%s %s', 'foo', 'bar', 'hop');
|
console.log('%s %s', 'foo', 'bar', 'hop');
|
||||||
console.log({slashes: '\\\\'})
|
console.log({slashes: '\\\\'});
|
||||||
|
|
||||||
global.process.stdout.write = stdout_write;
|
global.process.stdout.write = stdout_write;
|
||||||
assert.equal('foo\n', strings.shift());
|
assert.equal('foo\n', strings.shift());
|
||||||
@ -49,4 +49,4 @@ assert.equal('foo bar\n', strings.shift());
|
|||||||
assert.equal('foo bar hop\n', strings.shift());
|
assert.equal('foo bar hop\n', strings.shift());
|
||||||
assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
|
assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
|
||||||
|
|
||||||
assert.equal(true, process.stderr.write("hello world"));
|
assert.equal(true, process.stderr.write('hello world'));
|
||||||
|
@ -39,8 +39,10 @@ var path = require('path');
|
|||||||
var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
|
var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
|
||||||
var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
|
var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
|
||||||
var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
|
var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
|
||||||
var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', 'ascii');
|
var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
|
||||||
var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', 'ascii');
|
'ascii');
|
||||||
|
var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
|
||||||
|
'ascii');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var credentials = crypto.createCredentials(
|
var credentials = crypto.createCredentials(
|
||||||
@ -69,8 +71,8 @@ var rfc4231 = [
|
|||||||
sha224: '896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22',
|
sha224: '896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22',
|
||||||
sha256: 'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7',
|
sha256: 'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7',
|
||||||
sha384: 'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6',
|
sha384: 'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6',
|
||||||
sha512: '87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854',
|
sha512: '87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('4a656665', 'hex'), // 'Jefe'
|
key: new Buffer('4a656665', 'hex'), // 'Jefe'
|
||||||
@ -79,8 +81,8 @@ var rfc4231 = [
|
|||||||
sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44',
|
sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44',
|
||||||
sha256: '5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843',
|
sha256: '5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843',
|
||||||
sha384: 'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649',
|
sha384: 'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649',
|
||||||
sha512: '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737',
|
sha512: '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
@ -89,8 +91,8 @@ var rfc4231 = [
|
|||||||
sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
|
sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
|
||||||
sha256: '773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe',
|
sha256: '773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe',
|
||||||
sha384: '88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27',
|
sha384: '88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27',
|
||||||
sha512: 'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb',
|
sha512: 'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||||
@ -99,8 +101,8 @@ var rfc4231 = [
|
|||||||
sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
|
sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
|
||||||
sha256: '82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b',
|
sha256: '82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b',
|
||||||
sha384: '3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb',
|
sha384: '3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb',
|
||||||
sha512: 'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd',
|
sha512: 'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||||
@ -109,9 +111,9 @@ var rfc4231 = [
|
|||||||
sha224: '0e2aea68a90c8d37c988bcdb9fca6fa8',
|
sha224: '0e2aea68a90c8d37c988bcdb9fca6fa8',
|
||||||
sha256: 'a3b6167473100ee06e0c796c2955552b',
|
sha256: 'a3b6167473100ee06e0c796c2955552b',
|
||||||
sha384: '3abf34c3503b2a23a46efc619baef897',
|
sha384: '3abf34c3503b2a23a46efc619baef897',
|
||||||
sha512: '415fad6271580a531d4179bc891d87a6',
|
sha512: '415fad6271580a531d4179bc891d87a6'
|
||||||
},
|
},
|
||||||
truncate: true,
|
truncate: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
@ -120,8 +122,8 @@ var rfc4231 = [
|
|||||||
sha224: '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e',
|
sha224: '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e',
|
||||||
sha256: '60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54',
|
sha256: '60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54',
|
||||||
sha384: '4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952',
|
sha384: '4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952',
|
||||||
sha512: '80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598',
|
sha512: '80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
@ -130,9 +132,9 @@ var rfc4231 = [
|
|||||||
sha224: '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1',
|
sha224: '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1',
|
||||||
sha256: '9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2',
|
sha256: '9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2',
|
||||||
sha384: '6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e',
|
sha384: '6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e',
|
||||||
sha512: 'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58',
|
sha512: 'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58'
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
for (var i = 0, l = rfc4231.length; i < l; i++) {
|
for (var i = 0, l = rfc4231.length; i < l; i++) {
|
||||||
@ -145,7 +147,7 @@ for (var i = 0, l = rfc4231.length; i < l; i++) {
|
|||||||
}
|
}
|
||||||
assert.equal(rfc4231[i]['hmac'][hash],
|
assert.equal(rfc4231[i]['hmac'][hash],
|
||||||
result,
|
result,
|
||||||
"Test HMAC-" + hash + ": Test case " + (i+1) + " rfc 4231");
|
'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' rfc 4231');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,75 +156,75 @@ var rfc2202_md5 = [
|
|||||||
{
|
{
|
||||||
key: new Buffer('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
|
key: new Buffer('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
|
||||||
data: 'Hi There',
|
data: 'Hi There',
|
||||||
hmac: '9294727a3638bb1c13f48ef8158bfc9d',
|
hmac: '9294727a3638bb1c13f48ef8158bfc9d'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Jefe',
|
key: 'Jefe',
|
||||||
data: 'what do ya want for nothing?',
|
data: 'what do ya want for nothing?',
|
||||||
hmac: '750c783e6ab0b503eaa86e310a5db738',
|
hmac: '750c783e6ab0b503eaa86e310a5db738'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||||
hmac: '56be34521d144c88dbb8c733f0e8b3f6',
|
hmac: '56be34521d144c88dbb8c733f0e8b3f6'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||||
hmac: '697eaf0aca3a3aea3a75164746ffaa79',
|
hmac: '697eaf0aca3a3aea3a75164746ffaa79'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||||
data: 'Test With Truncation',
|
data: 'Test With Truncation',
|
||||||
hmac: '56461ef2342edc00f9bab995690efd4c',
|
hmac: '56461ef2342edc00f9bab995690efd4c'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
||||||
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd',
|
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
||||||
hmac: '6f630fad67cda0ee1fb1f562db3aa53e',
|
hmac: '6f630fad67cda0ee1fb1f562db3aa53e'
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
var rfc2202_sha1 = [
|
var rfc2202_sha1 = [
|
||||||
{
|
{
|
||||||
key: new Buffer('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
|
key: new Buffer('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
|
||||||
data: 'Hi There',
|
data: 'Hi There',
|
||||||
hmac: 'b617318655057264e28bc0b6fb378c8ef146be00',
|
hmac: 'b617318655057264e28bc0b6fb378c8ef146be00'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Jefe',
|
key: 'Jefe',
|
||||||
data: 'what do ya want for nothing?',
|
data: 'what do ya want for nothing?',
|
||||||
hmac: 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79',
|
hmac: 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||||
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3',
|
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||||
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da',
|
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||||
data: 'Test With Truncation',
|
data: 'Test With Truncation',
|
||||||
hmac: '4c1a03424b55e07fe7f27be1d58bb9324a9a5a04',
|
hmac: '4c1a03424b55e07fe7f27be1d58bb9324a9a5a04'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
||||||
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112',
|
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||||
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
||||||
hmac: 'e8e99d0f45237d786d6bbaa7965c7808bbff1a91',
|
hmac: 'e8e99d0f45237d786d6bbaa7965c7808bbff1a91'
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
for (var i = 0, l = rfc2202_md5.length; i < l; i++) {
|
for (var i = 0, l = rfc2202_md5.length; i < l; i++) {
|
||||||
@ -230,14 +232,14 @@ for (var i = 0, l = rfc2202_md5.length; i < l; i++) {
|
|||||||
crypto.createHmac('md5', rfc2202_md5[i]['key'])
|
crypto.createHmac('md5', rfc2202_md5[i]['key'])
|
||||||
.update(rfc2202_md5[i]['data'])
|
.update(rfc2202_md5[i]['data'])
|
||||||
.digest('hex'),
|
.digest('hex'),
|
||||||
"Test HMAC-MD5 : Test case " + (i+1) + " rfc 2202");
|
'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202');
|
||||||
}
|
}
|
||||||
for (var i = 0, l = rfc2202_sha1.length; i < l; i++) {
|
for (var i = 0, l = rfc2202_sha1.length; i < l; i++) {
|
||||||
assert.equal(rfc2202_sha1[i]['hmac'],
|
assert.equal(rfc2202_sha1[i]['hmac'],
|
||||||
crypto.createHmac('sha1', rfc2202_sha1[i]['key'])
|
crypto.createHmac('sha1', rfc2202_sha1[i]['key'])
|
||||||
.update(rfc2202_sha1[i]['data'])
|
.update(rfc2202_sha1[i]['data'])
|
||||||
.digest('hex'),
|
.digest('hex'),
|
||||||
"Test HMAC-SHA1 : Test case " + (i+1) + " rfc 2202");
|
'Test HMAC-SHA1 : Test case ' + (i + 1) + ' rfc 2202');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test hashing
|
// Test hashing
|
||||||
|
@ -35,11 +35,11 @@ p.onResponse = function (res) {
|
|||||||
resCount++;
|
resCount++;
|
||||||
};
|
};
|
||||||
|
|
||||||
p.execute("Type: connect\r\n" +
|
p.execute('Type: connect\r\n' +
|
||||||
"V8-Version: 3.0.4.1\r\n" +
|
'V8-Version: 3.0.4.1\r\n' +
|
||||||
"Protocol-Version: 1\r\n" +
|
'Protocol-Version: 1\r\n' +
|
||||||
"Embedding-Host: node v0.3.3-pre\r\n" +
|
'Embedding-Host: node v0.3.3-pre\r\n' +
|
||||||
"Content-Length: 0\r\n\r\n");
|
'Content-Length: 0\r\n\r\n');
|
||||||
assert.equal(1, resCount);
|
assert.equal(1, resCount);
|
||||||
|
|
||||||
// Make sure split messages go in.
|
// Make sure split messages go in.
|
||||||
@ -99,20 +99,20 @@ function addTest (cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTest(function(client, done) {
|
addTest(function(client, done) {
|
||||||
console.error("requesting version");
|
console.error('requesting version');
|
||||||
client.reqVersion(function(err, v) {
|
client.reqVersion(function(err, v) {
|
||||||
assert.ok(!err);
|
assert.ok(!err);
|
||||||
console.log("version: %s", v);
|
console.log('version: %s', v);
|
||||||
assert.equal(process.versions.v8, v);
|
assert.equal(process.versions.v8, v);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addTest(function(client, done) {
|
addTest(function(client, done) {
|
||||||
console.error("requesting scripts");
|
console.error('requesting scripts');
|
||||||
client.reqScripts(function(err) {
|
client.reqScripts(function(err) {
|
||||||
assert.ok(!err);
|
assert.ok(!err);
|
||||||
console.error("got %d scripts", Object.keys(client.scripts).length);
|
console.error('got %d scripts', Object.keys(client.scripts).length);
|
||||||
|
|
||||||
var foundMainScript = false;
|
var foundMainScript = false;
|
||||||
for (var k in client.scripts) {
|
for (var k in client.scripts) {
|
||||||
@ -128,8 +128,8 @@ addTest(function (client, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addTest(function(client, done) {
|
addTest(function(client, done) {
|
||||||
console.error("eval 2+2");
|
console.error('eval 2+2');
|
||||||
client.reqEval("2+2", function (err, res) {
|
client.reqEval('2+2', function(err, res) {
|
||||||
console.error(res);
|
console.error(res);
|
||||||
assert.ok(!err);
|
assert.ok(!err);
|
||||||
assert.equal('4', res.text);
|
assert.equal('4', res.text);
|
||||||
@ -146,14 +146,14 @@ function doTest(cb, done) {
|
|||||||
['-e', 'setInterval(function () { console.log("blah"); }, 100);']);
|
['-e', 'setInterval(function () { console.log("blah"); }, 100);']);
|
||||||
|
|
||||||
nodeProcess.stdout.once('data', function() {
|
nodeProcess.stdout.once('data', function() {
|
||||||
console.log(">>> new node process: %d", nodeProcess.pid);
|
console.log('>>> new node process: %d', nodeProcess.pid);
|
||||||
process.kill(nodeProcess.pid, "SIGUSR1");
|
process.kill(nodeProcess.pid, 'SIGUSR1');
|
||||||
console.log(">>> signaling it with SIGUSR1");
|
console.log('>>> signaling it with SIGUSR1');
|
||||||
});
|
});
|
||||||
|
|
||||||
var didTryConnect = false;
|
var didTryConnect = false;
|
||||||
nodeProcess.stderr.setEncoding('utf8');
|
nodeProcess.stderr.setEncoding('utf8');
|
||||||
var b = ''
|
var b = '';
|
||||||
nodeProcess.stderr.on('data', function(data) {
|
nodeProcess.stderr.on('data', function(data) {
|
||||||
b += data;
|
b += data;
|
||||||
if (didTryConnect == false && /debugger listening on port/.test(b)) {
|
if (didTryConnect == false && /debugger listening on port/.test(b)) {
|
||||||
@ -162,13 +162,13 @@ function doTest(cb, done) {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Wait for some data before trying to connect
|
// Wait for some data before trying to connect
|
||||||
var c = new debug.Client();
|
var c = new debug.Client();
|
||||||
process.stdout.write(">>> connecting...");
|
process.stdout.write('>>> connecting...');
|
||||||
c.connect(debug.port)
|
c.connect(debug.port);
|
||||||
c.on('ready', function() {
|
c.on('ready', function() {
|
||||||
connectCount++;
|
connectCount++;
|
||||||
console.log("ready!");
|
console.log('ready!');
|
||||||
cb(c, function() {
|
cb(c, function() {
|
||||||
console.error(">>> killing node process %d\n\n", nodeProcess.pid);
|
console.error('>>> killing node process %d\n\n', nodeProcess.pid);
|
||||||
nodeProcess.kill();
|
nodeProcess.kill();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -73,7 +73,7 @@ function addTest(input, output) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
expected.push({input: input, lines: output, callback: next});
|
expected.push({input: input, lines: output, callback: next});
|
||||||
};
|
}
|
||||||
|
|
||||||
// Initial lines
|
// Initial lines
|
||||||
addTest(null, [
|
addTest(null, [
|
||||||
@ -140,13 +140,13 @@ addTest('c, bt', [
|
|||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
};
|
}
|
||||||
|
|
||||||
function quit() {
|
function quit() {
|
||||||
if (quit.called) return;
|
if (quit.called) return;
|
||||||
quit.called = true;
|
quit.called = true;
|
||||||
child.stdin.write('quit');
|
child.stdin.write('quit');
|
||||||
};
|
}
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
throw new Error('timeout!');
|
throw new Error('timeout!');
|
||||||
|
@ -30,7 +30,8 @@ var path = require('path');
|
|||||||
var exits = 0;
|
var exits = 0;
|
||||||
|
|
||||||
function errExec(script, callback) {
|
function errExec(script, callback) {
|
||||||
var cmd = '"' + process.argv[0] + '" "' + path.join(common.fixturesDir, script) + '"';
|
var cmd = '"' + process.argv[0] + '" "' +
|
||||||
|
path.join(common.fixturesDir, script) + '"';
|
||||||
return exec(cmd, function(err, stdout, stderr) {
|
return exec(cmd, function(err, stdout, stderr) {
|
||||||
// There was some error
|
// There was some error
|
||||||
assert.ok(err);
|
assert.ok(err);
|
||||||
|
@ -30,8 +30,9 @@ var exec = require('child_process').exec;
|
|||||||
var success_count = 0;
|
var success_count = 0;
|
||||||
var error_count = 0;
|
var error_count = 0;
|
||||||
|
|
||||||
var cmd = [process.execPath, '-e', '"console.error(process.argv)"', 'foo', 'bar'].join(' ');
|
var cmd = [process.execPath, '-e', '"console.error(process.argv)"', 'foo', 'bar']
|
||||||
var expected = util.format([process.execPath, 'foo', 'bar']) + "\n";
|
.join(' ');
|
||||||
|
var expected = util.format([process.execPath, 'foo', 'bar']) + '\n';
|
||||||
var child = exec(cmd, function(err, stdout, stderr) {
|
var child = exec(cmd, function(err, stdout, stderr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err.toString());
|
console.log(err.toString());
|
||||||
|
@ -26,7 +26,8 @@ var fs = require('fs');
|
|||||||
|
|
||||||
var caughtException = false;
|
var caughtException = false;
|
||||||
try {
|
try {
|
||||||
// should throw ENOENT, not EBADF - see https://github.com/joyent/node/pull/1228
|
// should throw ENOENT, not EBADF
|
||||||
|
// see https://github.com/joyent/node/pull/1228
|
||||||
fs.openSync('/path/to/file/that/does/not/exist', 'r');
|
fs.openSync('/path/to/file/that/does/not/exist', 'r');
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -49,7 +49,7 @@ process.addListener('exit', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
fs.writeFileSync(filepathOne, "hello");
|
fs.writeFileSync(filepathOne, 'hello');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
function() {
|
function() {
|
||||||
@ -70,13 +70,13 @@ assert.doesNotThrow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
fs.writeFileSync(filepathOne, "world");
|
fs.writeFileSync(filepathOne, 'world');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
process.chdir(testDir);
|
process.chdir(testDir);
|
||||||
|
|
||||||
fs.writeFileSync(filepathTwoAbs, "howdy");
|
fs.writeFileSync(filepathTwoAbs, 'howdy');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
function() {
|
function() {
|
||||||
@ -97,5 +97,5 @@ assert.doesNotThrow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
fs.writeFileSync(filepathTwoAbs, "pardner");
|
fs.writeFileSync(filepathTwoAbs, 'pardner');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -56,7 +56,7 @@ process.addListener('exit', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
fs.writeFileSync(filepathOne, "hello");
|
fs.writeFileSync(filepathOne, 'hello');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
function() {
|
function() {
|
||||||
@ -83,13 +83,13 @@ assert.doesNotThrow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
fs.writeFileSync(filepathOne, "world");
|
fs.writeFileSync(filepathOne, 'world');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
process.chdir(testDir);
|
process.chdir(testDir);
|
||||||
|
|
||||||
fs.writeFileSync(filepathTwoAbs, "howdy");
|
fs.writeFileSync(filepathTwoAbs, 'howdy');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
function() {
|
function() {
|
||||||
@ -116,7 +116,7 @@ assert.doesNotThrow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
fs.writeFileSync(filepathTwoAbs, "pardner");
|
fs.writeFileSync(filepathTwoAbs, 'pardner');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
try { fs.unlinkSync(filepathThree); } catch (e) {}
|
try { fs.unlinkSync(filepathThree); } catch (e) {}
|
||||||
|
@ -105,25 +105,25 @@ function test(handler, request_generator, response_validator) {
|
|||||||
assert.equal(1, req.httpVersionMajor);
|
assert.equal(1, req.httpVersionMajor);
|
||||||
assert.equal(0, req.httpVersionMinor);
|
assert.equal(0, req.httpVersionMinor);
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||||
res.write("Hello, "); res._send('');
|
res.write('Hello, '); res._send('');
|
||||||
res.write("world!"); res._send('');
|
res.write('world!'); res._send('');
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
function request_generator() {
|
function request_generator() {
|
||||||
return ("GET / HTTP/1.0\r\n"
|
return ('GET / HTTP/1.0\r\n' +
|
||||||
+ "User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n"
|
'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' +
|
||||||
+ "Host: 127.0.0.1:1337\r\n"
|
'Host: 127.0.0.1:1337\r\n' +
|
||||||
+ "Accept: */*\r\n"
|
'Accept: */*\r\n' +
|
||||||
+ "\r\n");
|
'\r\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function response_validator(server_response, client_got_eof, timed_out) {
|
function response_validator(server_response, client_got_eof, timed_out) {
|
||||||
var expected_response = ("HTTP/1.1 200 OK\r\n"
|
var expected_response = ('HTTP/1.1 200 OK\r\n' +
|
||||||
+ "Content-Type: text/plain\r\n"
|
'Content-Type: text/plain\r\n' +
|
||||||
+ "Connection: close\r\n"
|
'Connection: close\r\n' +
|
||||||
+ "\r\n"
|
'\r\n' +
|
||||||
+ "Hello, world!");
|
'Hello, world!');
|
||||||
|
|
||||||
assert.equal(expected_response, server_response.data);
|
assert.equal(expected_response, server_response.data);
|
||||||
assert.equal(1, server_response.chunks.length);
|
assert.equal(1, server_response.chunks.length);
|
||||||
@ -140,32 +140,32 @@ function test(handler, request_generator, response_validator) {
|
|||||||
assert.equal(1, req.httpVersionMajor);
|
assert.equal(1, req.httpVersionMajor);
|
||||||
assert.equal(1, req.httpVersionMinor);
|
assert.equal(1, req.httpVersionMinor);
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||||
res.write("Hello, "); res._send('');
|
res.write('Hello, '); res._send('');
|
||||||
res.write("world!"); res._send('');
|
res.write('world!'); res._send('');
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
function request_generator() {
|
function request_generator() {
|
||||||
return ("GET / HTTP/1.1\r\n"
|
return ('GET / HTTP/1.1\r\n' +
|
||||||
+ "User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n"
|
'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' +
|
||||||
+ "Connection: close\r\n"
|
'Connection: close\r\n' +
|
||||||
+ "Host: 127.0.0.1:1337\r\n"
|
'Host: 127.0.0.1:1337\r\n' +
|
||||||
+ "Accept: */*\r\n"
|
'Accept: */*\r\n' +
|
||||||
+ "\r\n");
|
'\r\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function response_validator(server_response, client_got_eof, timed_out) {
|
function response_validator(server_response, client_got_eof, timed_out) {
|
||||||
var expected_response = ("HTTP/1.1 200 OK\r\n"
|
var expected_response = ('HTTP/1.1 200 OK\r\n' +
|
||||||
+ "Content-Type: text/plain\r\n"
|
'Content-Type: text/plain\r\n' +
|
||||||
+ "Connection: close\r\n"
|
'Connection: close\r\n' +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
'Transfer-Encoding: chunked\r\n' +
|
||||||
+ "\r\n"
|
'\r\n' +
|
||||||
+ "7\r\n"
|
'7\r\n' +
|
||||||
+ "Hello, \r\n"
|
'Hello, \r\n' +
|
||||||
+ "6\r\n"
|
'6\r\n' +
|
||||||
+ "world!\r\n"
|
'world!\r\n' +
|
||||||
+ "0\r\n"
|
'0\r\n' +
|
||||||
+ "\r\n");
|
'\r\n');
|
||||||
|
|
||||||
assert.equal(expected_response, server_response.data);
|
assert.equal(expected_response, server_response.data);
|
||||||
assert.equal(1, server_response.chunks.length);
|
assert.equal(1, server_response.chunks.length);
|
||||||
|
@ -19,43 +19,43 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
var common = require("../common");
|
var common = require('../common');
|
||||||
var http = require("http");
|
var http = require('http');
|
||||||
var assert = require("assert");
|
var assert = require('assert');
|
||||||
|
|
||||||
var server = http.Server(function(req, res) {
|
var server = http.Server(function(req, res) {
|
||||||
console.log("Server accepted request.");
|
console.log('Server accepted request.');
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write("Part of my res.");
|
res.write('Part of my res.');
|
||||||
|
|
||||||
res.destroy();
|
res.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
var responseClose = false
|
var responseClose = false;
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var client = http.get({
|
var client = http.get({
|
||||||
port: common.PORT,
|
port: common.PORT,
|
||||||
headers: { connection: "keep-alive" }
|
headers: { connection: 'keep-alive' }
|
||||||
|
|
||||||
}, function(res) {
|
}, function(res) {
|
||||||
server.close();
|
server.close();
|
||||||
|
|
||||||
console.log("Got res: " + res.statusCode);
|
console.log('Got res: ' + res.statusCode);
|
||||||
console.dir(res.headers);
|
console.dir(res.headers);
|
||||||
|
|
||||||
res.on("data", function (chunk) {
|
res.on('data', function(chunk) {
|
||||||
console.log("Read " + chunk.length + " bytes");
|
console.log('Read ' + chunk.length + ' bytes');
|
||||||
console.log(chunk.toString());
|
console.log(chunk.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
res.on("end", function () {
|
res.on('end', function() {
|
||||||
console.log("Response ended.");
|
console.log('Response ended.');
|
||||||
});
|
});
|
||||||
|
|
||||||
// it would be nice if this worked:
|
// it would be nice if this worked:
|
||||||
res.on("close", function () {
|
res.on('close', function() {
|
||||||
console.log("Response aborted");
|
console.log('Response aborted');
|
||||||
responseClose = true;
|
responseClose = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ var http = require('http');
|
|||||||
|
|
||||||
var server = http.Server(function(req, res) {
|
var server = http.Server(function(req, res) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
var responses = 0;
|
var responses = 0;
|
||||||
@ -39,7 +39,7 @@ server.listen(common.PORT, function() {
|
|||||||
for (var i = 0; i < N; i++) {
|
for (var i = 0; i < N; i++) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
for (var j = 0; j < M; j++) {
|
for (var j = 0; j < M; j++) {
|
||||||
http.get({ port: common.PORT, path: '/', }, function(res) {
|
http.get({ port: common.PORT, path: '/' }, function(res) {
|
||||||
console.log(res.statusCode);
|
console.log(res.statusCode);
|
||||||
if (++responses == N * M) server.close();
|
if (++responses == N * M) server.close();
|
||||||
}).on('error', function(e) {
|
}).on('error', function(e) {
|
||||||
|
@ -39,20 +39,24 @@ var server = http.createServer(function(req, res) {
|
|||||||
});
|
});
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var data = '';
|
var data = '';
|
||||||
var get = http.get({path:'/', host:'localhost', port:common.PORT}, function (x) {
|
var get = http.get({
|
||||||
x.setEncoding('utf8')
|
path: '/',
|
||||||
|
host: 'localhost',
|
||||||
|
port: common.PORT
|
||||||
|
}, function(x) {
|
||||||
|
x.setEncoding('utf8');
|
||||||
x.on('data', function(c) {data += c});
|
x.on('data', function(c) {data += c});
|
||||||
x.on('error', function(e) {
|
x.on('error', function(e) {
|
||||||
throw e;
|
throw e;
|
||||||
})
|
});
|
||||||
x.on('end', function() {
|
x.on('end', function() {
|
||||||
assert.equal('string', typeof data);
|
assert.equal('string', typeof data);
|
||||||
console.log('here is the response:');
|
console.log('here is the response:');
|
||||||
assert.equal(UTF8_STRING, data);
|
assert.equal(UTF8_STRING, data);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
server.close();
|
server.close();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
get.on('error', function(e) {throw e});
|
get.on('error', function(e) {throw e});
|
||||||
get.end();
|
get.end();
|
||||||
|
|
||||||
|
@ -26,26 +26,26 @@ var http = require('http');
|
|||||||
var clientAborts = 0;
|
var clientAborts = 0;
|
||||||
|
|
||||||
var server = http.Server(function(req, res) {
|
var server = http.Server(function(req, res) {
|
||||||
console.log("Got connection");
|
console.log('Got connection');
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write("Working on it...");
|
res.write('Working on it...');
|
||||||
|
|
||||||
// I would expect an error event from req or res that the client aborted
|
// I would expect an error event from req or res that the client aborted
|
||||||
// before completing the HTTP request / response cycle, or maybe a new
|
// before completing the HTTP request / response cycle, or maybe a new
|
||||||
// event like "aborted" or something.
|
// event like "aborted" or something.
|
||||||
req.on("aborted", function () {
|
req.on('aborted', function() {
|
||||||
clientAborts++;
|
clientAborts++;
|
||||||
console.log("Got abort " + clientAborts);
|
console.log('Got abort ' + clientAborts);
|
||||||
if (clientAborts === N) {
|
if (clientAborts === N) {
|
||||||
console.log("All aborts detected, you win.");
|
console.log('All aborts detected, you win.');
|
||||||
server.close();
|
server.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// since there is already clientError, maybe that would be appropriate,
|
// since there is already clientError, maybe that would be appropriate,
|
||||||
// since "error" is magical
|
// since "error" is magical
|
||||||
req.on("clientError", function () {
|
req.on('clientError', function() {
|
||||||
console.log("Got clientError");
|
console.log('Got clientError');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,18 +54,18 @@ var N = http.Agent.defaultMaxSockets - 1;
|
|||||||
var requests = [];
|
var requests = [];
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
console.log("Server listening.");
|
console.log('Server listening.');
|
||||||
|
|
||||||
for (var i = 0; i < N; i++) {
|
for (var i = 0; i < N; i++) {
|
||||||
console.log("Making client " + i);
|
console.log('Making client ' + i);
|
||||||
var options = { port: common.PORT, path: '/?id=' + i };
|
var options = { port: common.PORT, path: '/?id=' + i };
|
||||||
var req = http.get(options, function(res) {
|
var req = http.get(options, function(res) {
|
||||||
console.log("Client response code " + res.statusCode);
|
console.log('Client response code ' + res.statusCode);
|
||||||
|
|
||||||
if (++responses == N) {
|
if (++responses == N) {
|
||||||
console.log("All clients connected, destroying.");
|
console.log('All clients connected, destroying.');
|
||||||
requests.forEach(function(outReq) {
|
requests.forEach(function(outReq) {
|
||||||
console.log("abort");
|
console.log('abort');
|
||||||
outReq.abort();
|
outReq.abort();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -54,3 +54,4 @@ function onListen() {
|
|||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.equal(caughtError, true);
|
assert.equal(caughtError, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
if (!process.versions.openssl) {
|
if (!process.versions.openssl) {
|
||||||
console.error("Skipping because node compiled without OpenSSL.");
|
console.error('Skipping because node compiled without OpenSSL.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ function maybeMakeRequest() {
|
|||||||
|
|
||||||
|
|
||||||
var ddcmd = common.ddCommand(filename, 10240);
|
var ddcmd = common.ddCommand(filename, 10240);
|
||||||
console.log("dd command: ", ddcmd);
|
console.log('dd command: ', ddcmd);
|
||||||
|
|
||||||
cp.exec(ddcmd, function(err, stdout, stderr) {
|
cp.exec(ddcmd, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
@ -40,7 +40,7 @@ var server = http.Server(function(req, res) {
|
|||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
|
@ -36,7 +36,7 @@ host += host;
|
|||||||
host += host;
|
host += host;
|
||||||
|
|
||||||
function do_not_call() {
|
function do_not_call() {
|
||||||
throw new Error("This function should not have been called.");
|
throw new Error('This function should not have been called.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(mod) {
|
function test(mod) {
|
||||||
@ -68,3 +68,4 @@ test(http);
|
|||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.equal(actual_bad_requests, expected_bad_requests);
|
assert.equal(actual_bad_requests, expected_bad_requests);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@ var common = require('../common');
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
|
||||||
var resDespiteError = false
|
var resDespiteError = false;
|
||||||
var hadError = 0
|
var hadError = 0;
|
||||||
|
|
||||||
function httpreq(count) {
|
function httpreq(count) {
|
||||||
if ( 1 < count ) return
|
if (1 < count) return;
|
||||||
|
|
||||||
var req = http.request({
|
var req = http.request({
|
||||||
host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld',
|
host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld',
|
||||||
@ -40,20 +40,20 @@ function httpreq(count) {
|
|||||||
path: '/',
|
path: '/',
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
}, function(res) {
|
}, function(res) {
|
||||||
resDespiteError = true
|
resDespiteError = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on('error', function(e) {
|
req.on('error', function(e) {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
assert.strictEqual(e.code, 'ENOTFOUND');
|
assert.strictEqual(e.code, 'ENOTFOUND');
|
||||||
hadError++
|
hadError++;
|
||||||
httpreq(count + 1)
|
httpreq(count + 1);
|
||||||
})
|
});
|
||||||
|
|
||||||
req.end()
|
req.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
httpreq(0)
|
httpreq(0);
|
||||||
|
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
|
@ -32,7 +32,7 @@ var fs = require('fs');
|
|||||||
|
|
||||||
var image = fs.readFileSync(common.fixturesDir + '/person.jpg');
|
var image = fs.readFileSync(common.fixturesDir + '/person.jpg');
|
||||||
|
|
||||||
console.log("image.length = " + image.length);
|
console.log('image.length = ' + image.length);
|
||||||
|
|
||||||
var total = 100;
|
var total = 100;
|
||||||
var requests = 0, responses = 0;
|
var requests = 0, responses = 0;
|
||||||
@ -64,20 +64,20 @@ server.listen(common.PORT, function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
http.get(opts, function(res) {
|
http.get(opts, function(res) {
|
||||||
console.error("recv " + x);
|
console.error('recv ' + x);
|
||||||
var s = fs.createWriteStream(common.tmpDir + '/' + x + ".jpg");
|
var s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg');
|
||||||
res.pipe(s);
|
res.pipe(s);
|
||||||
|
|
||||||
// TODO there should be a callback to pipe() that will allow
|
// TODO there should be a callback to pipe() that will allow
|
||||||
// us to get a callback when the pipe is finished.
|
// us to get a callback when the pipe is finished.
|
||||||
res.on('end', function() {
|
res.on('end', function() {
|
||||||
console.error("done " + x);
|
console.error('done ' + x);
|
||||||
if (++responses == total) {
|
if (++responses == total) {
|
||||||
s.on('close', checkFiles);
|
s.on('close', checkFiles);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).on('error', function(e) {
|
}).on('error', function(e) {
|
||||||
console.error('error! ', e.message)
|
console.error('error! ', e.message);
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
@ -97,7 +97,7 @@ function checkFiles() {
|
|||||||
var stat = fs.statSync(common.tmpDir + '/' + fn);
|
var stat = fs.statSync(common.tmpDir + '/' + fn);
|
||||||
assert.equal(image.length, stat.size,
|
assert.equal(image.length, stat.size,
|
||||||
"size doesn't match on '" + fn +
|
"size doesn't match on '" + fn +
|
||||||
"'. Got " + stat.size + " bytes");
|
"'. Got " + stat.size + ' bytes');
|
||||||
}
|
}
|
||||||
|
|
||||||
checkedFiles = true;
|
checkedFiles = true;
|
||||||
|
@ -37,37 +37,55 @@ var connectCount = 0;
|
|||||||
|
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var agent = new http.Agent({maxSockets:1})
|
var agent = new http.Agent({ maxSockets: 1 });
|
||||||
var request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function () {
|
var request = http.request({
|
||||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
method: 'GET',
|
||||||
|
path: '/',
|
||||||
|
headers: headers,
|
||||||
|
port: common.PORT,
|
||||||
|
agent: agent
|
||||||
|
}, function() {
|
||||||
|
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||||
});
|
});
|
||||||
request.on('socket', function(s) {
|
request.on('socket', function(s) {
|
||||||
s.on('connect', function() {
|
s.on('connect', function() {
|
||||||
connectCount++;
|
connectCount++;
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
request.end();
|
request.end();
|
||||||
|
|
||||||
request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function () {
|
request = http.request({
|
||||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
method: 'GET',
|
||||||
|
path: '/',
|
||||||
|
headers: headers,
|
||||||
|
port: common.PORT,
|
||||||
|
agent: agent
|
||||||
|
}, function() {
|
||||||
|
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||||
});
|
});
|
||||||
request.on('socket', function(s) {
|
request.on('socket', function(s) {
|
||||||
s.on('connect', function() {
|
s.on('connect', function() {
|
||||||
connectCount++;
|
connectCount++;
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
request.end();
|
request.end();
|
||||||
request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function(response) {
|
request = http.request({
|
||||||
|
method: 'GET',
|
||||||
|
path: '/',
|
||||||
|
headers: headers,
|
||||||
|
port: common.PORT,
|
||||||
|
agent: agent
|
||||||
|
}, function(response) {
|
||||||
response.addListener('end', function() {
|
response.addListener('end', function() {
|
||||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
request.on('socket', function(s) {
|
request.on('socket', function(s) {
|
||||||
s.on('connect', function() {
|
s.on('connect', function() {
|
||||||
connectCount++;
|
connectCount++;
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
request.end();
|
request.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -36,19 +36,19 @@ var server = http.createServer(function(req, res) {
|
|||||||
var connectCount = 0;
|
var connectCount = 0;
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var agent = new http.Agent({maxSockets:1})
|
var agent = new http.Agent({maxSockets: 1});
|
||||||
var request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function() {
|
var request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function() {
|
||||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||||
});
|
});
|
||||||
request.end();
|
request.end();
|
||||||
|
|
||||||
request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function() {
|
request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function() {
|
||||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||||
});
|
});
|
||||||
request.end();
|
request.end();
|
||||||
request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function(response) {
|
request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function(response) {
|
||||||
response.addListener('end', function() {
|
response.addListener('end', function() {
|
||||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,7 @@ var server = http.Server(function(req, res) {
|
|||||||
requests++;
|
requests++;
|
||||||
assert.equal(req.connection, connection);
|
assert.equal(req.connection, connection);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.once('connection', function(c) {
|
server.once('connection', function(c) {
|
||||||
|
@ -28,16 +28,16 @@ var net = require('net');
|
|||||||
var gotResponse = false;
|
var gotResponse = false;
|
||||||
|
|
||||||
var server = net.createServer(function(conn) {
|
var server = net.createServer(function(conn) {
|
||||||
var body = "Yet another node.js server.";
|
var body = 'Yet another node.js server.';
|
||||||
|
|
||||||
var response =
|
var response =
|
||||||
"HTTP/1.1 200 OK\r\n" +
|
'HTTP/1.1 200 OK\r\n' +
|
||||||
"Connection: close\r\n" +
|
'Connection: close\r\n' +
|
||||||
"Content-Length: " + body.length + "\r\n" +
|
'Content-Length: ' + body.length + '\r\n' +
|
||||||
"Content-Type: text/plain;\r\n" +
|
'Content-Type: text/plain;\r\n' +
|
||||||
" x-unix-mode=0600;\r\n" +
|
' x-unix-mode=0600;\r\n' +
|
||||||
" name=\"hello.txt\"\r\n" +
|
' name=\"hello.txt\"\r\n' +
|
||||||
"\r\n" +
|
'\r\n' +
|
||||||
body;
|
body;
|
||||||
|
|
||||||
conn.write(response, function() {
|
conn.write(response, function() {
|
||||||
|
@ -130,7 +130,7 @@ function nextTest () {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw Error("?");
|
throw Error('?');
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setEncoding('utf8');
|
response.setEncoding('utf8');
|
||||||
|
@ -28,7 +28,7 @@ var http = require('http');
|
|||||||
|
|
||||||
var server = http.Server(function(req, res) {
|
var server = http.Server(function(req, res) {
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var req = http.get({port: common.PORT}, function(res) {
|
var req = http.get({port: common.PORT}, function(res) {
|
||||||
|
@ -37,7 +37,7 @@ var server = http.Server(function(req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
|
@ -30,20 +30,20 @@ var server = http.createServer(function(req, res) {
|
|||||||
res.write('a');
|
res.write('a');
|
||||||
|
|
||||||
req.on('close', function() {
|
req.on('close', function() {
|
||||||
console.error("aborted");
|
console.error('aborted');
|
||||||
gotEnd = true;
|
gotEnd = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
server.listen(common.PORT);
|
server.listen(common.PORT);
|
||||||
|
|
||||||
server.addListener('listening', function() {
|
server.addListener('listening', function() {
|
||||||
console.error("make req");
|
console.error('make req');
|
||||||
http.get({
|
http.get({
|
||||||
port: common.PORT
|
port: common.PORT
|
||||||
}, function(res) {
|
}, function(res) {
|
||||||
console.error("got res");
|
console.error('got res');
|
||||||
res.on('data', function(data) {
|
res.on('data', function(data) {
|
||||||
console.error("destroy res");
|
console.error('destroy res');
|
||||||
res.destroy();
|
res.destroy();
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
@ -45,7 +45,7 @@ server.listen(common.PORT, function() {
|
|||||||
x.on('error', function() {
|
x.on('error', function() {
|
||||||
clearTimeout(errorTimer);
|
clearTimeout(errorTimer);
|
||||||
console.log('HTTP REQUEST COMPLETE (this is good)');
|
console.log('HTTP REQUEST COMPLETE (this is good)');
|
||||||
})
|
});
|
||||||
x.end();
|
x.end();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -29,7 +29,8 @@ var headers_ok = false;
|
|||||||
var body_ok = false;
|
var body_ok = false;
|
||||||
|
|
||||||
var server = http.createServer(function(req, res) {
|
var server = http.createServer(function(req, res) {
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain',
|
res.writeHead(200, {
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
'Connection': 'close'
|
'Connection': 'close'
|
||||||
});
|
});
|
||||||
res.write('hello ');
|
res.write('hello ');
|
||||||
|
@ -82,7 +82,7 @@ srv.listen(common.PORT, '127.0.0.1', function() {
|
|||||||
srv.close();
|
srv.close();
|
||||||
|
|
||||||
gotUpgrade = true;
|
gotUpgrade = true;
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -40,13 +40,13 @@ var successCount = 0;
|
|||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
|
|
||||||
function upgradeRequest(fn) {
|
function upgradeRequest(fn) {
|
||||||
console.log("req");
|
console.log('req');
|
||||||
var header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' };
|
var header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' };
|
||||||
var request = http.request({ port: common.PORT, headers: header });
|
var request = http.request({ port: common.PORT, headers: header });
|
||||||
var wasUpgrade = false;
|
var wasUpgrade = false;
|
||||||
|
|
||||||
function onUpgrade(res, socket, head) {
|
function onUpgrade(res, socket, head) {
|
||||||
console.log("client upgraded");
|
console.log('client upgraded');
|
||||||
wasUpgrade = true;
|
wasUpgrade = true;
|
||||||
|
|
||||||
request.removeListener('upgrade', onUpgrade);
|
request.removeListener('upgrade', onUpgrade);
|
||||||
@ -55,7 +55,7 @@ server.listen(common.PORT, function() {
|
|||||||
request.on('upgrade', onUpgrade);
|
request.on('upgrade', onUpgrade);
|
||||||
|
|
||||||
function onEnd() {
|
function onEnd() {
|
||||||
console.log("client end");
|
console.log('client end');
|
||||||
request.removeListener('end', onEnd);
|
request.removeListener('end', onEnd);
|
||||||
if (!wasUpgrade) {
|
if (!wasUpgrade) {
|
||||||
throw new Error('hasn\'t received upgrade event');
|
throw new Error('hasn\'t received upgrade event');
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
if (!process.versions.openssl) {
|
if (!process.versions.openssl) {
|
||||||
console.error("Skipping because node compiled without OpenSSL.");
|
console.error('Skipping because node compiled without OpenSSL.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ var options = {
|
|||||||
|
|
||||||
var server = https.Server(options, function(req, res) {
|
var server = https.Server(options, function(req, res) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ server.listen(common.PORT, function() {
|
|||||||
for (var i = 0; i < N; i++) {
|
for (var i = 0; i < N; i++) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
for (var j = 0; j < M; j++) {
|
for (var j = 0; j < M; j++) {
|
||||||
https.get({ port: common.PORT, path: '/', }, function(res) {
|
https.get({ port: common.PORT, path: '/' }, function(res) {
|
||||||
console.log(res.statusCode);
|
console.log(res.statusCode);
|
||||||
if (++responses == N * M) server.close();
|
if (++responses == N * M) server.close();
|
||||||
}).on('error', function(e) {
|
}).on('error', function(e) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
if (!process.versions.openssl) {
|
if (!process.versions.openssl) {
|
||||||
console.error("Skipping because node compiled without OpenSSL.");
|
console.error('Skipping because node compiled without OpenSSL.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ var exponent;
|
|||||||
|
|
||||||
var server = https.createServer(options, function(req, res) {
|
var server = https.createServer(options, function(req, res) {
|
||||||
reqCount++;
|
reqCount++;
|
||||||
console.log("got request");
|
console.log('got request');
|
||||||
|
|
||||||
cert = req.connection.getPeerCertificate();
|
cert = req.connection.getPeerCertificate();
|
||||||
|
|
||||||
@ -58,14 +58,14 @@ var server = https.createServer(options, function (req, res) {
|
|||||||
|
|
||||||
res.writeHead(200, { 'content-type': 'text/plain' });
|
res.writeHead(200, { 'content-type': 'text/plain' });
|
||||||
res.end(body);
|
res.end(body);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/';
|
var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/';
|
||||||
cmd += ' --cert ' + join(common.fixturesDir, 'foafssl.crt');
|
cmd += ' --cert ' + join(common.fixturesDir, 'foafssl.crt');
|
||||||
cmd += ' --key ' + join(common.fixturesDir, 'foafssl.key');
|
cmd += ' --key ' + join(common.fixturesDir, 'foafssl.key');
|
||||||
console.error("executing %j", cmd);
|
console.error('executing %j', cmd);
|
||||||
exec(cmd, function(err, stdout, stderr) {
|
exec(cmd, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
common.error(common.inspect(stdout));
|
common.error(common.inspect(stdout));
|
||||||
@ -77,12 +77,13 @@ server.listen(common.PORT, function () {
|
|||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.equal(subjectaltname, 'URI:http://example.com/#me');
|
assert.equal(subjectaltname, 'URI:http://example.com/#me');
|
||||||
assert.equal(modulus, 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC\
|
assert.equal(modulus, 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09' +
|
||||||
3A5519F349CD9B9C40BE436D0AA823A94147E26C89248ADA2BE3DD4D34E8C28964694B2047D217\
|
'BBC3A5519F349CD9B9C40BE436D0AA823A94147E26C89248ADA2BE3DD4D34E8C2896' +
|
||||||
B4F1299371EA93A83C89AB9440724131E65F2B0161DE9560CDE9C13455552B2F49CF0FB00D8D77\
|
'4694B2047D217B4F1299371EA93A83C89AB9440724131E65F2B0161DE9560CDE9C13' +
|
||||||
532324913F6F80FF29D0A131D29DB06AFF8BE191B7920DC2DAE1C26EA82A47847A10391EF3BF6A\
|
'455552B2F49CF0FB00D8D77532324913F6F80FF29D0A131D29DB06AFF8BE191B7920' +
|
||||||
ABB3CC40FF82100B03A4F0FF1809278E4DDFDA7DE954ED56DC7AD9A47EEBC37D771A366FC60A5B\
|
'DC2DAE1C26EA82A47847A10391EF3BF6AABB3CC40FF82100B03A4F0FF1809278E4DD' +
|
||||||
CB72373BEC180649B3EFA0E9092707210B41B90032BB18BC91F2046EBDAF1191F4A4E26D71879C\
|
'FDA7DE954ED56DC7AD9A47EEBC37D771A366FC60A5BCB72373BEC180649B3EFA0E90' +
|
||||||
4C7867B62FCD508E8CE66E82D128A71E915809FCF44E8DE774067F1DE5D70B9C03687');
|
'92707210B41B90032BB18BC91F2046EBDAF1191F4A4E26D71879C4C7867B62FCD508' +
|
||||||
|
'E8CE66E82D128A71E915809FCF44E8DE774067F1DE5D70B9C03687');
|
||||||
assert.equal(exponent, '10001');
|
assert.equal(exponent, '10001');
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
if (!process.versions.openssl) {
|
if (!process.versions.openssl) {
|
||||||
console.error("Skipping because node compiled without OpenSSL.");
|
console.error('Skipping because node compiled without OpenSSL.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,15 +45,15 @@ var body = 'hello world\n';
|
|||||||
|
|
||||||
var server = https.createServer(options, function(req, res) {
|
var server = https.createServer(options, function(req, res) {
|
||||||
reqCount++;
|
reqCount++;
|
||||||
console.log("got request");
|
console.log('got request');
|
||||||
res.writeHead(200, { 'content-type': 'text/plain' });
|
res.writeHead(200, { 'content-type': 'text/plain' });
|
||||||
res.end(body);
|
res.end(body);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/';
|
var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/';
|
||||||
console.error("executing %j", cmd);
|
console.error('executing %j', cmd);
|
||||||
exec(cmd, function(err, stdout, stderr) {
|
exec(cmd, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
common.error(common.inspect(stdout));
|
common.error(common.inspect(stdout));
|
||||||
@ -62,7 +62,7 @@ server.listen(common.PORT, function () {
|
|||||||
// Do the same thing now without --insecure
|
// Do the same thing now without --insecure
|
||||||
// The connection should not be accepted.
|
// The connection should not be accepted.
|
||||||
var cmd = 'curl https://127.0.0.1:' + common.PORT + '/';
|
var cmd = 'curl https://127.0.0.1:' + common.PORT + '/';
|
||||||
console.error("executing %j", cmd);
|
console.error('executing %j', cmd);
|
||||||
exec(cmd, function(err, stdout, stderr) {
|
exec(cmd, function(err, stdout, stderr) {
|
||||||
assert.ok(err);
|
assert.ok(err);
|
||||||
server.close();
|
server.close();
|
||||||
|
@ -55,7 +55,7 @@ checkExpected();
|
|||||||
|
|
||||||
|
|
||||||
// Now do the test again after we console.log something.
|
// Now do the test again after we console.log something.
|
||||||
console.log("load console.log. process.stdout._type is " +
|
console.log('load console.log. process.stdout._type is ' +
|
||||||
process.stdout._type);
|
process.stdout._type);
|
||||||
|
|
||||||
if (!process.features.uv) {
|
if (!process.features.uv) {
|
||||||
@ -78,7 +78,7 @@ if (!process.features.uv) {
|
|||||||
case 'fs':
|
case 'fs':
|
||||||
expected = expected.concat([
|
expected = expected.concat([
|
||||||
'NativeModule console',
|
'NativeModule console',
|
||||||
'Binding tty_wrap',
|
'Binding tty_wrap'
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -102,17 +102,17 @@ if (!process.features.uv) {
|
|||||||
'NativeModule timers_uv',
|
'NativeModule timers_uv',
|
||||||
'Binding timer_wrap',
|
'Binding timer_wrap',
|
||||||
'NativeModule _linklist',
|
'NativeModule _linklist',
|
||||||
'Binding pipe_wrap',
|
'Binding pipe_wrap'
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert.ok(0, "prcoess.stdout._type is bad");
|
assert.ok(0, 'prcoess.stdout._type is bad');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error("process.moduleLoadList", process.moduleLoadList)
|
console.error('process.moduleLoadList', process.moduleLoadList);
|
||||||
console.error("expected", expected)
|
console.error('expected', expected);
|
||||||
|
|
||||||
checkExpected();
|
checkExpected();
|
||||||
|
|
||||||
|
@ -199,9 +199,11 @@ assert.equal(child.loaded, parent.loaded);
|
|||||||
|
|
||||||
// #1357 Loading JSON files with require()
|
// #1357 Loading JSON files with require()
|
||||||
var json = require('../fixtures/packages/main/package.json');
|
var json = require('../fixtures/packages/main/package.json');
|
||||||
assert.deepEqual(json, { name: 'package-name',
|
assert.deepEqual(json, {
|
||||||
|
name: 'package-name',
|
||||||
version: '1.2.3',
|
version: '1.2.3',
|
||||||
main: 'package-main-module' });
|
main: 'package-main-module'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
process.addListener('exit', function() {
|
process.addListener('exit', function() {
|
||||||
|
@ -64,7 +64,7 @@ tcp.listen(common.PORT, function () {
|
|||||||
socket.connect(tcpPort);
|
socket.connect(tcpPort);
|
||||||
} else {
|
} else {
|
||||||
tcp.close();
|
tcp.close();
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ tcp.listen(common.PORT, function () {
|
|||||||
var r = socket.write('foo', function() {
|
var r = socket.write('foo', function() {
|
||||||
fooWritten = true;
|
fooWritten = true;
|
||||||
assert.ok(connectHappened);
|
assert.ok(connectHappened);
|
||||||
console.error("foo written");
|
console.error('foo written');
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(false, r);
|
assert.equal(false, r);
|
||||||
|
@ -47,7 +47,7 @@ var socket0 = net.createConnection(9999, 'google.com');
|
|||||||
socket0.setTimeout(T);
|
socket0.setTimeout(T);
|
||||||
|
|
||||||
socket0.on('timeout', function() {
|
socket0.on('timeout', function() {
|
||||||
console.error("timeout");
|
console.error('timeout');
|
||||||
gotTimeout0 = true;
|
gotTimeout0 = true;
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
assert.ok(now - start < T + 500);
|
assert.ok(now - start < T + 500);
|
||||||
@ -55,7 +55,7 @@ socket0.on('timeout', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket0.on('connect', function() {
|
socket0.on('connect', function() {
|
||||||
console.error("connect");
|
console.error('connect');
|
||||||
gotConnect0 = true;
|
gotConnect0 = true;
|
||||||
socket0.destroy();
|
socket0.destroy();
|
||||||
});
|
});
|
||||||
@ -68,7 +68,7 @@ var socket1 = net.createConnection(9999, '24.24.24.24');
|
|||||||
socket1.setTimeout(T);
|
socket1.setTimeout(T);
|
||||||
|
|
||||||
socket1.on('timeout', function() {
|
socket1.on('timeout', function() {
|
||||||
console.error("timeout");
|
console.error('timeout');
|
||||||
gotTimeout1 = true;
|
gotTimeout1 = true;
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
assert.ok(now - start < T + 500);
|
assert.ok(now - start < T + 500);
|
||||||
@ -76,7 +76,7 @@ socket1.on('timeout', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket1.on('connect', function() {
|
socket1.on('connect', function() {
|
||||||
console.error("connect");
|
console.error('connect');
|
||||||
gotConnect1 = true;
|
gotConnect1 = true;
|
||||||
socket1.destroy();
|
socket1.destroy();
|
||||||
});
|
});
|
||||||
|
@ -43,12 +43,12 @@ var server2 = net.Server(function (socket) {
|
|||||||
var server2errors = 0;
|
var server2errors = 0;
|
||||||
server2.on('error', function() {
|
server2.on('error', function() {
|
||||||
server2errors++;
|
server2errors++;
|
||||||
console.error("server2 error");
|
console.error('server2 error');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
server1.listen(common.PORT, function() {
|
server1.listen(common.PORT, function() {
|
||||||
console.error("server1 listening");
|
console.error('server1 listening');
|
||||||
server1listening = true;
|
server1listening = true;
|
||||||
// This should make server2 emit EADDRINUSE
|
// This should make server2 emit EADDRINUSE
|
||||||
server2.listen(common.PORT);
|
server2.listen(common.PORT);
|
||||||
@ -59,7 +59,7 @@ server1.listen(common.PORT, function () {
|
|||||||
// here.
|
// here.
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
server2.listen(common.PORT + 1, function() {
|
server2.listen(common.PORT + 1, function() {
|
||||||
console.error("server2 listening");
|
console.error('server2 listening');
|
||||||
server2listening = true;
|
server2listening = true;
|
||||||
|
|
||||||
server1.close();
|
server1.close();
|
||||||
|
@ -33,7 +33,7 @@ s.server = new net.Server();
|
|||||||
s.server.connections = 10;
|
s.server.connections = 10;
|
||||||
|
|
||||||
assert.equal(10, s.server.connections);
|
assert.equal(10, s.server.connections);
|
||||||
s.destroy()
|
s.destroy();
|
||||||
assert.equal(9, s.server.connections);
|
assert.equal(9, s.server.connections);
|
||||||
s.destroy()
|
s.destroy();
|
||||||
assert.equal(9, s.server.connections);
|
assert.equal(9, s.server.connections);
|
||||||
|
@ -27,32 +27,32 @@ var assert = require('assert');
|
|||||||
var os = require('os');
|
var os = require('os');
|
||||||
|
|
||||||
|
|
||||||
var hostname = os.hostname()
|
var hostname = os.hostname();
|
||||||
console.log("hostname = %s", hostname);
|
console.log('hostname = %s', hostname);
|
||||||
assert.ok(hostname.length > 0);
|
assert.ok(hostname.length > 0);
|
||||||
|
|
||||||
var uptime = os.uptime();
|
var uptime = os.uptime();
|
||||||
console.log("uptime = %d", uptime);
|
console.log('uptime = %d', uptime);
|
||||||
assert.ok(uptime > 0);
|
assert.ok(uptime > 0);
|
||||||
|
|
||||||
var cpus = os.cpus();
|
var cpus = os.cpus();
|
||||||
console.log("cpus = ", cpus);
|
console.log('cpus = ', cpus);
|
||||||
assert.ok(cpus.length > 0);
|
assert.ok(cpus.length > 0);
|
||||||
|
|
||||||
var type = os.type();
|
var type = os.type();
|
||||||
console.log("type = ", type);
|
console.log('type = ', type);
|
||||||
assert.ok(type.length > 0);
|
assert.ok(type.length > 0);
|
||||||
|
|
||||||
var release = os.release();
|
var release = os.release();
|
||||||
console.log("release = ", release);
|
console.log('release = ', release);
|
||||||
assert.ok(release.length > 0);
|
assert.ok(release.length > 0);
|
||||||
|
|
||||||
var platform = os.platform();
|
var platform = os.platform();
|
||||||
console.log("platform = ", platform);
|
console.log('platform = ', platform);
|
||||||
assert.ok(platform.length > 0);
|
assert.ok(platform.length > 0);
|
||||||
|
|
||||||
var arch = os.arch();
|
var arch = os.arch();
|
||||||
console.log("arch = ", arch);
|
console.log('arch = ', arch);
|
||||||
assert.ok(arch.length > 0);
|
assert.ok(arch.length > 0);
|
||||||
|
|
||||||
if (process.platform != 'sunos') {
|
if (process.platform != 'sunos') {
|
||||||
|
@ -197,7 +197,7 @@ if (isWindows) {
|
|||||||
[['.'], process.cwd()],
|
[['.'], process.cwd()],
|
||||||
[['/some/dir', '.', '/absolute/'], '/absolute']];
|
[['/some/dir', '.', '/absolute/'], '/absolute']];
|
||||||
}
|
}
|
||||||
var failures = []
|
var failures = [];
|
||||||
resolveTests.forEach(function(test) {
|
resolveTests.forEach(function(test) {
|
||||||
var actual = path.resolve.apply(path, test[0]);
|
var actual = path.resolve.apply(path, test[0]);
|
||||||
var expected = test[1];
|
var expected = test[1];
|
||||||
|
@ -59,7 +59,7 @@ server.listen(common.PORT);
|
|||||||
|
|
||||||
server.on('listening', function() {
|
server.on('listening', function() {
|
||||||
var cmd = common.ddCommand(filename, 10240);
|
var cmd = common.ddCommand(filename, 10240);
|
||||||
console.log("dd command: ", cmd);
|
console.log('dd command: ', cmd);
|
||||||
|
|
||||||
cp.exec(cmd, function(err, stdout, stderr) {
|
cp.exec(cmd, function(err, stdout, stderr) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
@ -44,7 +44,7 @@ function test(clazz, cb) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
conn.on('data', function(data) {
|
conn.on('data', function(data) {
|
||||||
assert.equal(data.toString(), 'PONG')
|
assert.equal(data.toString(), 'PONG');
|
||||||
have_pong = true;
|
have_pong = true;
|
||||||
conn.destroy();
|
conn.destroy();
|
||||||
});
|
});
|
||||||
@ -56,7 +56,7 @@ function test(clazz, cb) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
conn.on('data', function(data) {
|
conn.on('data', function(data) {
|
||||||
assert.equal(data.toString(), 'PING')
|
assert.equal(data.toString(), 'PING');
|
||||||
have_ping = true;
|
have_ping = true;
|
||||||
conn.write('PONG', 'utf-8');
|
conn.write('PONG', 'utf-8');
|
||||||
});
|
});
|
||||||
@ -83,3 +83,4 @@ function test(clazz, cb) {
|
|||||||
test(net.Stream, function() {
|
test(net.Stream, function() {
|
||||||
test(net.Socket);
|
test(net.Socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ var gotPipeEOF = false;
|
|||||||
var gotPipeData = false;
|
var gotPipeData = false;
|
||||||
|
|
||||||
p.onexit = function(exitCode, signal) {
|
p.onexit = function(exitCode, signal) {
|
||||||
console.log("exit");
|
console.log('exit');
|
||||||
p.close();
|
p.close();
|
||||||
pipe.readStart();
|
pipe.readStart();
|
||||||
|
|
||||||
@ -42,22 +42,22 @@ p.onexit = function(exitCode, signal) {
|
|||||||
assert.equal(0, signal);
|
assert.equal(0, signal);
|
||||||
|
|
||||||
processExited = true;
|
processExited = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
pipe.onread = function(b, off, len) {
|
pipe.onread = function(b, off, len) {
|
||||||
assert.ok(processExited);
|
assert.ok(processExited);
|
||||||
if (b) {
|
if (b) {
|
||||||
gotPipeData = true;
|
gotPipeData = true;
|
||||||
console.log("read %d", len);
|
console.log('read %d', len);
|
||||||
} else {
|
} else {
|
||||||
gotPipeEOF = true;
|
gotPipeEOF = true;
|
||||||
pipe.close();
|
pipe.close();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
p.spawn({
|
p.spawn({
|
||||||
file: process.execPath,
|
file: process.execPath,
|
||||||
args: [ process.execPath, "-v" ],
|
args: [process.execPath, '-v'],
|
||||||
stdoutStream: pipe
|
stdoutStream: pipe
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
if (!process.versions.openssl) {
|
if (!process.versions.openssl) {
|
||||||
console.error("Skipping because node compiled without OpenSSL.");
|
console.error('Skipping because node compiled without OpenSSL.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ var gotCallback = false;
|
|||||||
|
|
||||||
var server = https.createServer(options, function(req, res) {
|
var server = https.createServer(options, function(req, res) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end("hello world\n");
|
res.end('hello world\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
|
@ -59,6 +59,6 @@ child.on('exit', function (code) {
|
|||||||
|
|
||||||
child.stdout.pipe(process.stdout);
|
child.stdout.pipe(process.stdout);
|
||||||
|
|
||||||
child.stdout.on("close", function() {
|
child.stdout.on('close', function() {
|
||||||
console.error("child.stdout close gen=%d", gen);
|
console.error('child.stdout close gen=%d', gen);
|
||||||
});
|
});
|
||||||
|
@ -31,18 +31,18 @@ server.on('listening', pingping);
|
|||||||
|
|
||||||
|
|
||||||
function serverOn() {
|
function serverOn() {
|
||||||
console.error("Server ON");
|
console.error('Server ON');
|
||||||
server.listen(common.PORT);
|
server.listen(common.PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function serverOff() {
|
function serverOff() {
|
||||||
console.error("Server OFF");
|
console.error('Server OFF');
|
||||||
server.close();
|
server.close();
|
||||||
pingping();
|
pingping();
|
||||||
}
|
}
|
||||||
|
|
||||||
var responses = []
|
var responses = [];
|
||||||
|
|
||||||
|
|
||||||
function afterPing(result) {
|
function afterPing(result) {
|
||||||
@ -78,7 +78,7 @@ function afterPing(result) {
|
|||||||
|
|
||||||
|
|
||||||
function ping() {
|
function ping() {
|
||||||
console.error("making req");
|
console.error('making req');
|
||||||
|
|
||||||
var opt = {
|
var opt = {
|
||||||
port: common.PORT,
|
port: common.PORT,
|
||||||
@ -98,7 +98,7 @@ function ping() {
|
|||||||
assert.equal('PONG', body);
|
assert.equal('PONG', body);
|
||||||
assert.ok(!hadError);
|
assert.ok(!hadError);
|
||||||
gotEnd = true;
|
gotEnd = true;
|
||||||
afterPing("success");
|
afterPing('success');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ function ping() {
|
|||||||
var hadError = false;
|
var hadError = false;
|
||||||
|
|
||||||
req.on('error', function(error) {
|
req.on('error', function(error) {
|
||||||
console.log("Error making ping req: " + error);
|
console.log('Error making ping req: ' + error);
|
||||||
hadError = true;
|
hadError = true;
|
||||||
assert.ok(!gotEnd);
|
assert.ok(!gotEnd);
|
||||||
afterPing(error.message);
|
afterPing(error.message);
|
||||||
|
@ -3,5 +3,5 @@ var net = require('net');
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
// Connect to something that we need to DNS resolve
|
// Connect to something that we need to DNS resolve
|
||||||
var c = net.createConnection(80, "google.com");
|
var c = net.createConnection(80, 'google.com');
|
||||||
c.destroy();
|
c.destroy();
|
||||||
|
@ -14,11 +14,11 @@ var server = http.createServer(function (req, res) {
|
|||||||
res.end('Hello World\n');
|
res.end('Hello World\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, "127.0.0.1", function() {
|
server.listen(common.PORT, '127.0.0.1', function() {
|
||||||
for (var i = 0; i < N; i++) {
|
for (var i = 0; i < N; i++) {
|
||||||
var options = {
|
var options = {
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: common.PORT,
|
port: common.PORT
|
||||||
};
|
};
|
||||||
|
|
||||||
var req = http.get(options, function(res) {
|
var req = http.get(options, function(res) {
|
||||||
|
@ -34,7 +34,7 @@ var spawn = require('child_process').spawn;
|
|||||||
var https = require('https');
|
var https = require('https');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
var PORT = 8000
|
var PORT = 8000;
|
||||||
|
|
||||||
|
|
||||||
var bytesExpected = 1024 * 1024 * 32;
|
var bytesExpected = 1024 * 1024 * 32;
|
||||||
@ -98,11 +98,11 @@ var server = https.Server(serverOptions, function(req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, function() {
|
||||||
console.log("expecting %d bytes", bytesExpected);
|
console.log('expecting %d bytes', bytesExpected);
|
||||||
makeRequest();
|
makeRequest();
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
console.error("got %d bytes", uploadCount);
|
console.error('got %d bytes', uploadCount);
|
||||||
assert.equal(uploadCount, bytesExpected);
|
assert.equal(uploadCount, bytesExpected);
|
||||||
});
|
});
|
||||||
|
@ -123,12 +123,12 @@ function error_test() {
|
|||||||
{ client: client_unix, send: 'function blah() { return 1; }',
|
{ client: client_unix, send: 'function blah() { return 1; }',
|
||||||
expect: prompt_unix },
|
expect: prompt_unix },
|
||||||
{ client: client_unix, send: 'blah()',
|
{ client: client_unix, send: 'blah()',
|
||||||
expect: "1\n" + prompt_unix },
|
expect: '1\n' + prompt_unix },
|
||||||
// Multiline object
|
// Multiline object
|
||||||
{ client: client_unix, send: '{ a: ',
|
{ client: client_unix, send: '{ a: ',
|
||||||
expect: prompt_multiline },
|
expect: prompt_multiline },
|
||||||
{ client: client_unix, send: '1 }',
|
{ client: client_unix, send: '1 }',
|
||||||
expect: "{ a: 1 }" },
|
expect: '{ a: 1 }' },
|
||||||
// Multiline anonymous function with comment
|
// Multiline anonymous function with comment
|
||||||
{ client: client_unix, send: '(function () {',
|
{ client: client_unix, send: '(function () {',
|
||||||
expect: prompt_multiline },
|
expect: prompt_multiline },
|
||||||
@ -137,7 +137,7 @@ function error_test() {
|
|||||||
{ client: client_unix, send: 'return 1;',
|
{ client: client_unix, send: 'return 1;',
|
||||||
expect: prompt_multiline },
|
expect: prompt_multiline },
|
||||||
{ client: client_unix, send: '})()',
|
{ client: client_unix, send: '})()',
|
||||||
expect: "1" },
|
expect: '1' }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ function unix_test() {
|
|||||||
{ client: client_unix, send: 'a = 12345\n',
|
{ client: client_unix, send: 'a = 12345\n',
|
||||||
expect: ('12345' + '\n' + prompt_unix) },
|
expect: ('12345' + '\n' + prompt_unix) },
|
||||||
{ client: client_unix, send: '{a:1}\n',
|
{ client: client_unix, send: '{a:1}\n',
|
||||||
expect: ('{ a: 1 }' + '\n' + prompt_unix) },
|
expect: ('{ a: 1 }' + '\n' + prompt_unix) }
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ require('../fixtures/a.js');
|
|||||||
require('./../fixtures/a.js');
|
require('./../fixtures/a.js');
|
||||||
require('http');
|
require('http');
|
||||||
|
|
||||||
console.log("counterBefore = %d", counter);
|
console.log('counterBefore = %d', counter);
|
||||||
var counterBefore = counter;
|
var counterBefore = counter;
|
||||||
|
|
||||||
// Now load the module a bunch of times with equivalent paths.
|
// Now load the module a bunch of times with equivalent paths.
|
||||||
@ -66,7 +66,7 @@ for (var i = 0; i < 100; i++) {
|
|||||||
require('http');
|
require('http');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("counterAfter = %d", counter);
|
console.log('counterAfter = %d', counter);
|
||||||
var counterAfter = counter;
|
var counterAfter = counter;
|
||||||
|
|
||||||
assert.equal(counterBefore, counterAfter);
|
assert.equal(counterBefore, counterAfter);
|
||||||
|
@ -31,7 +31,8 @@ var fs = require('fs');
|
|||||||
var stdoutScript = join(common.fixturesDir, 'echo.js');
|
var stdoutScript = join(common.fixturesDir, 'echo.js');
|
||||||
var tmpFile = join(common.fixturesDir, 'stdin.txt');
|
var tmpFile = join(common.fixturesDir, 'stdin.txt');
|
||||||
|
|
||||||
var cmd = '"' + process.argv[0] + '" "' + stdoutScript + '" < "' + tmpFile + '"';
|
var cmd = '"' + process.argv[0] + '" "' + stdoutScript + '" < "' +
|
||||||
|
tmpFile + '"';
|
||||||
|
|
||||||
var string = 'abc\nümlaut.\nsomething else\n' +
|
var string = 'abc\nümlaut.\nsomething else\n' +
|
||||||
'南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,' +
|
'南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,' +
|
||||||
|
@ -34,11 +34,11 @@ function Writable () {
|
|||||||
util.inherits(Writable, stream.Stream);
|
util.inherits(Writable, stream.Stream);
|
||||||
Writable.prototype.end = function() {
|
Writable.prototype.end = function() {
|
||||||
this.endCalls++;
|
this.endCalls++;
|
||||||
}
|
};
|
||||||
|
|
||||||
Writable.prototype.destroy = function() {
|
Writable.prototype.destroy = function() {
|
||||||
this.endCalls++;
|
this.endCalls++;
|
||||||
}
|
};
|
||||||
|
|
||||||
function Readable() {
|
function Readable() {
|
||||||
this.readable = true;
|
this.readable = true;
|
||||||
@ -53,14 +53,14 @@ var w = new Writable();
|
|||||||
|
|
||||||
console.error = function(text) {
|
console.error = function(text) {
|
||||||
throw new Error(text);
|
throw new Error(text);
|
||||||
}
|
};
|
||||||
|
|
||||||
var r;
|
var r;
|
||||||
|
|
||||||
for (i = 0; i < limit; i++) {
|
for (i = 0; i < limit; i++) {
|
||||||
r = new Readable()
|
r = new Readable();
|
||||||
r.pipe(w)
|
r.pipe(w);
|
||||||
r.emit('end')
|
r.emit('end');
|
||||||
}
|
}
|
||||||
assert.equal(0, r.listeners('end').length);
|
assert.equal(0, r.listeners('end').length);
|
||||||
assert.equal(limit, w.endCalls);
|
assert.equal(limit, w.endCalls);
|
||||||
@ -68,9 +68,9 @@ assert.equal(limit, w.endCalls);
|
|||||||
w.endCalls = 0;
|
w.endCalls = 0;
|
||||||
|
|
||||||
for (i = 0; i < limit; i++) {
|
for (i = 0; i < limit; i++) {
|
||||||
r = new Readable()
|
r = new Readable();
|
||||||
r.pipe(w)
|
r.pipe(w);
|
||||||
r.emit('close')
|
r.emit('close');
|
||||||
}
|
}
|
||||||
assert.equal(0, r.listeners('close').length);
|
assert.equal(0, r.listeners('close').length);
|
||||||
assert.equal(limit, w.endCalls);
|
assert.equal(limit, w.endCalls);
|
||||||
@ -78,13 +78,13 @@ assert.equal(limit, w.endCalls);
|
|||||||
w.endCalls = 0;
|
w.endCalls = 0;
|
||||||
|
|
||||||
var r2;
|
var r2;
|
||||||
r = new Readable()
|
r = new Readable();
|
||||||
r2 = new Readable();
|
r2 = new Readable();
|
||||||
|
|
||||||
r.pipe(w)
|
r.pipe(w);
|
||||||
r2.pipe(w)
|
r2.pipe(w);
|
||||||
r.emit('close')
|
r.emit('close');
|
||||||
r2.emit('close')
|
r2.emit('close');
|
||||||
assert.equal(1, w.endCalls);
|
assert.equal(1, w.endCalls);
|
||||||
|
|
||||||
r = new Readable();
|
r = new Readable();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user