CryptoStream.prototype.readyState shoudn't reference fd

Fixes #1069
This commit is contained in:
Ryan Dahl 2011-05-20 10:08:08 -07:00
parent 2de0611b43
commit 9c7f89bf56
2 changed files with 22 additions and 3 deletions

View File

@ -216,9 +216,23 @@ CryptoStream.prototype._done = function() {
};
CryptoStream.prototype.fd = -1;
CryptoStream.prototype.__defineGetter__('readyState',
net.Socket.prototype.__lookupGetter__('readyState'));
// readyState is deprecated. Don't use it.
Object.defineProperty(CryptoStream.prototype, 'readyState', {
get: function() {
if (this._connecting) {
return 'opening';
} else if (this.readable && this.writable) {
return 'open';
} else if (this.readable && !this.writable) {
return 'readOnly';
} else if (!this.readable && this.writable) {
return 'writeOnly';
} else {
return 'closed';
}
}
});
// Move decrypted, clear data out into the application.
// From the user's perspective this occurs as a 'data' event

View File

@ -54,6 +54,11 @@ server.listen(common.PORT, function() {
client.on('close', function() {
// readyState is deprecated but we want to make
// sure this isn't triggering an assert in lib/net.js
// See issue #1069.
assert.equal('closed', client.readyState);
assert.equal(buffer, message);
console.log(message);
server.close();