Ben Copsey

Move delegate authentication retries onto request thread

... ... @@ -23,7 +23,7 @@
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.7-25 2010-07-22";
NSString *ASIHTTPRequestVersion = @"v1.7-34 2010-07-27";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -176,6 +176,8 @@ static NSOperationQueue *sharedQueue = nil;
// Called when the status of the network changes
+ (void)reachabilityChanged:(NSNotification *)note;
- (void)failAuthentication;
#endif
@property (assign) BOOL complete;
... ... @@ -2164,12 +2166,17 @@ static NSOperationQueue *sharedQueue = nil;
// Called by delegate or authentication dialog to resume loading once authentication info has been populated
- (void)retryUsingSuppliedCredentials
{
[self attemptToApplyCredentialsAndResume];
[self performSelector:@selector(attemptToApplyCredentialsAndResume) onThread:[[self class] threadForRequest:self] withObject:nil waitUntilDone:NO];
}
// Called by delegate or authentication dialog to cancel authentication
- (void)cancelAuthentication
{
[self performSelector:@selector(failAuthentication) onThread:[[self class] threadForRequest:self] withObject:nil waitUntilDone:NO];
}
- (void)failAuthentication
{
[self failWithError:ASIAuthenticationError];
}
... ...
... ... @@ -76,6 +76,7 @@
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel_%28abridged%29.txt"]];
[request startAsynchronous];
[request cancel];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
GHAssertNotNil([request error],@"Failed to cancel the request");
// Test cancelling a redirected request works
... ... @@ -85,6 +86,7 @@
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
[request cancel];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
BOOL success = ([[[request url] absoluteString] isEqualToString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel.txt"]);
... ...