Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix GH-820. CryptoStream.end shouldn't throw if not writable
Browse files Browse the repository at this point in the history
This matches the behavior of net.Socket
  • Loading branch information
ry committed Mar 21, 2011
1 parent 4198de2 commit 7e28630
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};


Expand Down

0 comments on commit 7e28630

Please sign in to comment.