Ben Copsey

Move delegate authentication retries onto request thread

@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 23
24 24
25 // Automatically set on build 25 // Automatically set on build
26 -NSString *ASIHTTPRequestVersion = @"v1.7-25 2010-07-22"; 26 +NSString *ASIHTTPRequestVersion = @"v1.7-34 2010-07-27";
27 27
28 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; 28 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
29 29
@@ -176,6 +176,8 @@ static NSOperationQueue *sharedQueue = nil; @@ -176,6 +176,8 @@ static NSOperationQueue *sharedQueue = nil;
176 // Called when the status of the network changes 176 // Called when the status of the network changes
177 + (void)reachabilityChanged:(NSNotification *)note; 177 + (void)reachabilityChanged:(NSNotification *)note;
178 178
  179 +- (void)failAuthentication;
  180 +
179 #endif 181 #endif
180 182
181 @property (assign) BOOL complete; 183 @property (assign) BOOL complete;
@@ -2164,12 +2166,17 @@ static NSOperationQueue *sharedQueue = nil; @@ -2164,12 +2166,17 @@ static NSOperationQueue *sharedQueue = nil;
2164 // Called by delegate or authentication dialog to resume loading once authentication info has been populated 2166 // Called by delegate or authentication dialog to resume loading once authentication info has been populated
2165 - (void)retryUsingSuppliedCredentials 2167 - (void)retryUsingSuppliedCredentials
2166 { 2168 {
2167 - [self attemptToApplyCredentialsAndResume]; 2169 + [self performSelector:@selector(attemptToApplyCredentialsAndResume) onThread:[[self class] threadForRequest:self] withObject:nil waitUntilDone:NO];
2168 } 2170 }
2169 2171
2170 // Called by delegate or authentication dialog to cancel authentication 2172 // Called by delegate or authentication dialog to cancel authentication
2171 - (void)cancelAuthentication 2173 - (void)cancelAuthentication
2172 { 2174 {
  2175 + [self performSelector:@selector(failAuthentication) onThread:[[self class] threadForRequest:self] withObject:nil waitUntilDone:NO];
  2176 +}
  2177 +
  2178 +- (void)failAuthentication
  2179 +{
2173 [self failWithError:ASIAuthenticationError]; 2180 [self failWithError:ASIAuthenticationError];
2174 } 2181 }
2175 2182
@@ -76,6 +76,7 @@ @@ -76,6 +76,7 @@
76 ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel_%28abridged%29.txt"]]; 76 ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel_%28abridged%29.txt"]];
77 [request startAsynchronous]; 77 [request startAsynchronous];
78 [request cancel]; 78 [request cancel];
  79 + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
79 GHAssertNotNil([request error],@"Failed to cancel the request"); 80 GHAssertNotNil([request error],@"Failed to cancel the request");
80 81
81 // Test cancelling a redirected request works 82 // Test cancelling a redirected request works
@@ -85,6 +86,7 @@ @@ -85,6 +86,7 @@
85 86
86 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]]; 87 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
87 [request cancel]; 88 [request cancel];
  89 + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
88 90
89 BOOL success = ([[[request url] absoluteString] isEqualToString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel.txt"]); 91 BOOL success = ([[[request url] absoluteString] isEqualToString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel.txt"]);
90 92