@@ -253,35 +253,37 @@ isEqual: @"chunked"]; objc_autoreleasePoolPop(pool); } -- (void)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length +- (size_t)lowlevelWriteBuffer: (const void *)buffer + length: (size_t)length { + /* TODO: Use non-blocking writes */ + void *pool; if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (!_headersSent) [self of_sendHeaders]; - if (!_chunked) { - [_socket writeBuffer: buffer - length: length]; - return; - } + if (!_chunked) + return [_socket writeBuffer: buffer + length: length]; pool = objc_autoreleasePoolPush(); [_socket writeString: [OFString stringWithFormat: @"%zx\r\n", length]]; objc_autoreleasePoolPop(pool); [_socket writeBuffer: buffer length: length]; [_socket writeBuffer: "\r\n" length: 2]; + + return length; } - (void)close { if (_socket == nil)