Merge pull request #1539 from kylef/output-stream

Fixes an issue writing partial data to the output stream
This commit is contained in:
Mattt Thompson 2013-10-25 09:38:53 -07:00
commit eb828f08ab

View File

@ -609,7 +609,7 @@ didReceiveResponse:(NSURLResponse *)response
NSInteger numberOfBytesWritten = 0;
while (totalNumberOfBytesWritten < (NSInteger)length) {
numberOfBytesWritten = [self.outputStream write:&dataBuffer[0] maxLength:length];
numberOfBytesWritten = [self.outputStream write:&dataBuffer[totalNumberOfBytesWritten] maxLength:(length - totalNumberOfBytesWritten)];
if (numberOfBytesWritten == -1) {
[self.connection cancel];
[self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError];