Fix stupid regression that broke download progress
You can never have enough tests! :)
Showing
2 changed files
with
20 additions
and
1 deletions
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | #import "ASIInputStream.h" | 21 | #import "ASIInputStream.h" |
22 | 22 | ||
23 | // Automatically set on build | 23 | // Automatically set on build |
24 | -NSString *ASIHTTPRequestVersion = @"v1.2-72 2010-01-06"; | 24 | +NSString *ASIHTTPRequestVersion = @"v1.5-1 2010-01-08"; |
25 | 25 | ||
26 | NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; | 26 | NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; |
27 | 27 | ||
@@ -2367,6 +2367,10 @@ static BOOL isiPhoneOS2; | @@ -2367,6 +2367,10 @@ static BOOL isiPhoneOS2; | ||
2367 | 2367 | ||
2368 | - (void)handleBytesAvailable | 2368 | - (void)handleBytesAvailable |
2369 | { | 2369 | { |
2370 | + if (![self responseHeaders]) { | ||
2371 | + [self readResponseHeaders]; | ||
2372 | + } | ||
2373 | + | ||
2370 | // In certain (presumably very rare) circumstances, handleBytesAvailable seems to be called when there isn't actually any data available | 2374 | // In certain (presumably very rare) circumstances, handleBytesAvailable seems to be called when there isn't actually any data available |
2371 | // We'll check that there is actually data available to prevent blocking on CFReadStreamRead() | 2375 | // We'll check that there is actually data available to prevent blocking on CFReadStreamRead() |
2372 | // So far, I've only seen this in the stress tests, so it might never happen in real-world situations. | 2376 | // So far, I've only seen this in the stress tests, so it might never happen in real-world situations. |
@@ -446,6 +446,21 @@ | @@ -446,6 +446,21 @@ | ||
446 | 446 | ||
447 | BOOL success = (progress == 1.0); | 447 | BOOL success = (progress == 1.0); |
448 | GHAssertTrue(success,@"Failed to properly increment download progress %f != 1.0",progress); | 448 | GHAssertTrue(success,@"Failed to properly increment download progress %f != 1.0",progress); |
449 | + | ||
450 | + progress = 0; | ||
451 | + request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel.txt"]]; | ||
452 | + [request setDownloadProgressDelegate:self]; | ||
453 | + [request startAsynchronous]; | ||
454 | + | ||
455 | + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; | ||
456 | + | ||
457 | + success = (progress != 1.0); | ||
458 | + GHAssertTrue(success,@"Downloaded too quickly, cannot proceed with test"); | ||
459 | + | ||
460 | + success = (progress > 0); | ||
461 | + GHAssertTrue(success,@"Either downloaded too slowly, or progress is not being correctly updated"); | ||
462 | + | ||
463 | + | ||
449 | } | 464 | } |
450 | 465 | ||
451 | - (void)testUploadProgress | 466 | - (void)testUploadProgress |
-
Please register or login to post a comment