diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-12-09 19:47:55 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-12-10 22:56:01 +0400 |
commit | 4a2792cd2f86403a71edf65d82600b6aad5713bf (patch) | |
tree | 5e932adf6547f8231ecc08b381b88cf12569f5a7 /lib | |
parent | 92bbd60a3ffaf7b22e29576d720027cc835bf60e (diff) |
tls: emit 'end' on .receivedShutdown
NOTE: Also removed `.receivedShutdown` method of `Connection` it wasn't
documented anywhere, and was rewritten with `true` after receiving
`close_notify`.
fix #6638
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tls.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/tls.js b/lib/tls.js index ab2704445f9..5d04da59fe7 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -486,16 +486,21 @@ CryptoStream.prototype._read = function read(size) { if (bytesRead === 0) { // EOF when cleartext has finished and we have nothing to read - if (this._opposite._finished && this._internallyPendingBytes() === 0) { + if (this._opposite._finished && this._internallyPendingBytes() === 0 || + this.pair.ssl && this.pair.ssl.receivedShutdown) { // Perform graceful shutdown this._done(); // No half-open, sorry! - if (this === this.pair.cleartext) + if (this === this.pair.cleartext) { this._opposite._done(); - // EOF - this.push(null); + // EOF + this.push(null); + } else if (!this.pair.ssl || !this.pair.ssl.receivedShutdown) { + // EOF + this.push(null); + } } else { // Bail out this.push(''); |