fix style in net.js

This commit is contained in:
Ryan Dahl 2010-09-28 11:05:10 -07:00
parent fe060916ec
commit d89f8dce28

View File

@ -52,9 +52,9 @@ var END_OF_FILE = 42;
try { try {
var SecureContext = process.binding('crypto').SecureContext; var SecureContext = process.binding('crypto').SecureContext;
var SecureStream = process.binding('crypto').SecureStream; var SecureStream = process.binding('crypto').SecureStream;
var have_crypto = true; var haveCrypto = true;
} catch (e) { } catch (e) {
var have_crypto = false; var haveCrypto = false;
} }
// IDLE TIMEOUTS // IDLE TIMEOUTS
@ -336,9 +336,9 @@ function setImplmentationMethods (self) {
allocNewSecurePool(); allocNewSecurePool();
} }
var secureLen = self.secureStream.writeExtract( var secureLen = self.secureStream.writeExtract(securePool,
securePool, 0, securePool.length 0,
); securePool.length);
if (secureLen == -1) { if (secureLen == -1) {
// Check our read again for secure handshake // Check our read again for secure handshake
@ -376,12 +376,10 @@ function setImplmentationMethods (self) {
var chunkBytes; var chunkBytes;
do { do {
chunkBytes = self.secureStream.readExtract( chunkBytes =
pool, self.secureStream.readExtract(pool,
pool.used + bytesRead, pool.used + bytesRead,
pool.length - pool.used - bytesRead pool.length - pool.used - bytesRead);
);
bytesRead += chunkBytes; bytesRead += chunkBytes;
} while ((chunkBytes > 0) && (pool.used + bytesRead < pool.length)); } while ((chunkBytes > 0) && (pool.used + bytesRead < pool.length));
@ -391,8 +389,7 @@ function setImplmentationMethods (self) {
if (self.secureStream.readPending()) { if (self.secureStream.readPending()) {
process.nextTick(function () { process.nextTick(function () {
if(self._readWatcher) if (self._readWatcher) self._readWatcher.callback();
self._readWatcher.callback();
}); });
} }
@ -466,7 +463,10 @@ function initStream (self) {
var bytesRead; var bytesRead;
try { try {
bytesRead = self._readImpl(pool, pool.used, pool.length - pool.used, (arguments.length > 0)); bytesRead = self._readImpl(pool,
pool.used,
pool.length - pool.used,
(arguments.length > 0));
} catch (e) { } catch (e) {
self.destroy(e); self.destroy(e);
return; return;
@ -545,7 +545,7 @@ sys.inherits(Stream, events.EventEmitter);
exports.Stream = Stream; exports.Stream = Stream;
Stream.prototype.setSecure = function (credentials) { Stream.prototype.setSecure = function (credentials) {
if (!have_crypto) { if (!haveCrypto) {
throw new Error('node.js not compiled with openssl crypto support.'); throw new Error('node.js not compiled with openssl crypto support.');
} }
var crypto= require("crypto"); var crypto= require("crypto");
@ -558,10 +558,12 @@ Stream.prototype.setSecure = function(credentials) {
this.credentials = credentials; this.credentials = credentials;
} }
if (!this.server) { if (!this.server) {
// For clients, we will always have either a given ca list or the default one; // For clients, we will always have either a given ca list or the default on
this.credentials.shouldVerify = true; this.credentials.shouldVerify = true;
} }
this.secureStream = new SecureStream(this.credentials.context, this.server ? 1 : 0, this.credentials.shouldVerify ? 1 : 0); this.secureStream = new SecureStream(this.credentials.context,
this.server ? 1 : 0,
this.credentials.shouldVerify ? 1 : 0);
setImplmentationMethods(this); setImplmentationMethods(this);