Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -46,10 +46,12 @@ #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" + +#import "socket_helpers.h" #define REDIRECTS_DEFAULT 10 @interface OFHTTPClientRequestHandler: OFObject { @@ -880,19 +882,13 @@ if (ret > length) @throw [OFOutOfRangeException exception]; _toRead -= ret; - if (_toRead == 0) { + if (_toRead == 0) _atEndOfStream = true; - if (!_keepAlive) { - [_socket release]; - _socket = nil; - } - } - return ret; } /* Chunked */ if (_toRead > 0) { @@ -949,13 +945,10 @@ } if (line.length > 0) @throw [OFInvalidServerReplyException exception]; - } else { - [_socket release]; - _socket = nil; } } objc_autoreleasePoolPop(pool); @@ -978,11 +971,11 @@ } - (int)fileDescriptorForReading { if (_socket == nil) - return -1; + return INVALID_SOCKET; return _socket.fileDescriptorForReading; } - (bool)hasDataInReadBuffer