Fixes an issue writing partial data to output stream

This will manifest in a way where you will get duplicate data because it will
write the same data again and again.
This commit is contained in:
Kyle Fuller 2013-10-25 11:57:16 +01:00
parent 99e1ba8042
commit 0ec8817ff4

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];