Browse Source

Fix GH-820. CryptoStream.end shouldn't throw if not writable

This matches the behavior of net.Socket
v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
7e28630f5e
  1. 26
      lib/tls.js

26
lib/tls.js

@ -168,25 +168,23 @@ CryptoStream.prototype.getCipher = function(err) {
CryptoStream.prototype.end = function(d) {
if (!this.writable) {
throw new Error('CryptoStream is not writable');
}
if (this.pair._done) return;
if (this.writable) {
if (this.pair._done) return;
if (d) {
this.write(d);
}
if (d) {
this.write(d);
}
this._pending.push(END_OF_FILE);
this._pendingCallbacks.push(null);
this._pending.push(END_OF_FILE);
this._pendingCallbacks.push(null);
// If this is an encrypted stream then we need to disable further 'data'
// events.
// If this is an encrypted stream then we need to disable further 'data'
// events.
this.writable = false;
this.writable = false;
this.pair._cycle();
this.pair._cycle();
}
};

Loading…
Cancel
Save