Index: src/tls/OFGnuTLSTLSStream.m ================================================================== --- src/tls/OFGnuTLSTLSStream.m +++ src/tls/OFGnuTLSTLSStream.m @@ -17,10 +17,11 @@ #include #import "OFGnuTLSTLSStream.h" #import "OFData.h" +#import "OFStream+Private.h" #import "OFAlreadyOpenException.h" #import "OFInitializationFailedException.h" #import "OFNotOpenException.h" #import "OFReadFailedException.h" @@ -190,10 +191,26 @@ if (gnutls_record_check_pending(_session) > 0) return true; return super.hasDataInReadBuffer; } + +- (bool)of_isWaitingForDelimiter +{ + /* FIXME: There should be a non-private API for this. */ + + /* + * If we still have pending data in the session, we haven't processed + * it yet to see if our delimiter is in there. So return false here, as + * that will signal the stream as ready for reading, which in turn will + * cause a read and checking for the delimiter. + */ + if (gnutls_record_check_pending(_session) > 0) + return false; + + return super.of_waitingForDelimiter; +} - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode { static const OFTLSStreamErrorCode initFailedErrorCode = Index: src/tls/OFSecureTransportTLSStream.m ================================================================== --- src/tls/OFSecureTransportTLSStream.m +++ src/tls/OFSecureTransportTLSStream.m @@ -16,10 +16,11 @@ #include "config.h" #include #import "OFSecureTransportTLSStream.h" +#import "OFStream+Private.h" #import "OFAlreadyOpenException.h" #import "OFNotOpenException.h" #import "OFReadFailedException.h" #import "OFTLSHandshakeFailedException.h" @@ -176,10 +177,29 @@ bufferSize > 0) return true; return super.hasDataInReadBuffer; } + +- (bool)of_isWaitingForDelimiter +{ + size_t bufferSize; + + /* FIXME: There should be a non-private API for this. */ + + /* + * If we still have pending data in the context, we haven't processed + * it yet to see if our delimiter is in there. So return false here, as + * that will signal the stream as ready for reading, which in turn will + * cause a read and checking for the delimiter. + */ + if (SSLGetBufferedReadSize(_context, &bufferSize) == noErr && + bufferSize > 0) + return false; + + return super.of_waitingForDelimiter; +} - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode { static const OFTLSStreamErrorCode initFailedErrorCode =