Ben Copsey

Fix stupid regression that broke download progress

You can never have enough tests! :)
... ... @@ -21,7 +21,7 @@
#import "ASIInputStream.h"
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.2-72 2010-01-06";
NSString *ASIHTTPRequestVersion = @"v1.5-1 2010-01-08";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -2367,6 +2367,10 @@ static BOOL isiPhoneOS2;
- (void)handleBytesAvailable
{
if (![self responseHeaders]) {
[self readResponseHeaders];
}
// In certain (presumably very rare) circumstances, handleBytesAvailable seems to be called when there isn't actually any data available
// We'll check that there is actually data available to prevent blocking on CFReadStreamRead()
// So far, I've only seen this in the stress tests, so it might never happen in real-world situations.
... ...
... ... @@ -446,6 +446,21 @@
BOOL success = (progress == 1.0);
GHAssertTrue(success,@"Failed to properly increment download progress %f != 1.0",progress);
progress = 0;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel.txt"]];
[request setDownloadProgressDelegate:self];
[request startAsynchronous];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
success = (progress != 1.0);
GHAssertTrue(success,@"Downloaded too quickly, cannot proceed with test");
success = (progress > 0);
GHAssertTrue(success,@"Either downloaded too slowly, or progress is not being correctly updated");
}
- (void)testUploadProgress
... ...