@@ -31,13 +31,13 @@ #import "OFHTTPRequestFailedException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" #import "OFNotImplementedException.h" +#import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "OFReadFailedException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" @@ -126,14 +126,15 @@ } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { + if (_socket == nil) + @throw [OFNotOpenException exceptionWithObject: self]; + if (_atEndOfStream) - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length - errNo: ENOTCONN]; + return 0; if (!_hasContentLength && !_chunked) return [_socket readIntoBuffer: buffer length: length]; @@ -229,10 +230,13 @@ } } - (bool)lowlevelIsAtEndOfStream { + if (_socket == nil) + @throw [OFNotOpenException exceptionWithObject: self]; + if (!_hasContentLength && !_chunked) return [_socket isAtEndOfStream]; return _atEndOfStream; }