Refactor session credentials storage to store multiple sets of credentials, and …
…perform some checking to see if we should apply the credentials Tweak test
Showing
3 changed files
with
21 additions
and
13 deletions
| @@ -388,8 +388,8 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | @@ -388,8 +388,8 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | ||
| 388 | #pragma mark http authentication stuff | 388 | #pragma mark http authentication stuff |
| 389 | 389 | ||
| 390 | // Apply credentials to this request | 390 | // Apply credentials to this request |
| 391 | -- (BOOL)applyCredentials:(NSMutableDictionary *)newCredentials; | 391 | +- (BOOL)applyCredentials:(NSDictionary *)newCredentials; |
| 392 | -- (BOOL)applyProxyCredentials:(NSMutableDictionary *)newCredentials; | 392 | +- (BOOL)applyProxyCredentials:(NSDictionary *)newCredentials; |
| 393 | 393 | ||
| 394 | // Attempt to obtain credentials for this request from the URL, username and password or keychain | 394 | // Attempt to obtain credentials for this request from the URL, username and password or keychain |
| 395 | - (NSMutableDictionary *)findCredentials; | 395 | - (NSMutableDictionary *)findCredentials; |
| @@ -414,17 +414,25 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | @@ -414,17 +414,25 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | ||
| 414 | - (void)handleStreamComplete; | 414 | - (void)handleStreamComplete; |
| 415 | - (void)handleStreamError; | 415 | - (void)handleStreamError; |
| 416 | 416 | ||
| 417 | -#pragma mark managing the session | 417 | +# pragma mark session credentials |
| 418 | + | ||
| 419 | ++ (NSMutableArray *)sessionProxyCredentialsStore; | ||
| 420 | ++ (NSMutableArray *)sessionCredentialsStore; | ||
| 421 | + | ||
| 422 | ++ (void)storeProxyAuthenticationCredentialsInSessionStore:(NSDictionary *)credentials; | ||
| 423 | ++ (void)storeAuthenticationCredentialsInSessionStore:(NSDictionary *)credentials; | ||
| 424 | + | ||
| 425 | ++ (void)removeProxyAuthenticationCredentialsFromSessionStore:(NSDictionary *)credentials; | ||
| 426 | ++ (void)removeAuthenticationCredentialsFromSessionStore:(NSDictionary *)credentials; | ||
| 427 | + | ||
| 428 | +- (NSDictionary *)findSessionProxyAuthenticationCredentials; | ||
| 429 | +- (NSDictionary *)findSessionAuthenticationCredentials; | ||
| 418 | 430 | ||
| 419 | -+ (void)setSessionCredentials:(NSMutableDictionary *)newCredentials; | ||
| 420 | -+ (void)setSessionAuthentication:(CFHTTPAuthenticationRef)newAuthentication; | ||
| 421 | -+ (void)setSessionProxyCredentials:(NSMutableDictionary *)newCredentials; | ||
| 422 | -+ (void)setSessionProxyAuthentication:(CFHTTPAuthenticationRef)newAuthentication; | ||
| 423 | 431 | ||
| 424 | #pragma mark keychain storage | 432 | #pragma mark keychain storage |
| 425 | 433 | ||
| 426 | // Save credentials for this request to the keychain | 434 | // Save credentials for this request to the keychain |
| 427 | -- (void)saveCredentialsToKeychain:(NSMutableDictionary *)newCredentials; | 435 | +- (void)saveCredentialsToKeychain:(NSDictionary *)newCredentials; |
| 428 | 436 | ||
| 429 | // Save credentials to the keychain | 437 | // Save credentials to the keychain |
| 430 | + (void)saveCredentials:(NSURLCredential *)credentials forHost:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm; | 438 | + (void)saveCredentials:(NSURLCredential *)credentials forHost:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm; |
This diff is collapsed. Click to expand it.
| @@ -625,7 +625,7 @@ IMPORTANT | @@ -625,7 +625,7 @@ IMPORTANT | ||
| 625 | [self setFinishedRequests:[[[NSMutableArray alloc] init] autorelease]]; | 625 | [self setFinishedRequests:[[[NSMutableArray alloc] init] autorelease]]; |
| 626 | [self setImmediateCancelQueue:[[[NSOperationQueue alloc] init] autorelease]]; | 626 | [self setImmediateCancelQueue:[[[NSOperationQueue alloc] init] autorelease]]; |
| 627 | int i; | 627 | int i; |
| 628 | - for (i=0; i<100; i++) { | 628 | + for (i=0; i<25; i++) { |
| 629 | ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]]; | 629 | ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]]; |
| 630 | [request setDelegate:self]; | 630 | [request setDelegate:self]; |
| 631 | [request setDidFailSelector:@selector(immediateCancelFail:)]; | 631 | [request setDidFailSelector:@selector(immediateCancelFail:)]; |
| @@ -645,8 +645,8 @@ IMPORTANT | @@ -645,8 +645,8 @@ IMPORTANT | ||
| 645 | GHFail(@"A request that had already finished called its fail delegate method"); | 645 | GHFail(@"A request that had already finished called its fail delegate method"); |
| 646 | } | 646 | } |
| 647 | [[self failedRequests] addObject:request]; | 647 | [[self failedRequests] addObject:request]; |
| 648 | - if ([[self failedRequests] count]+[[self finishedRequests] count] > 100) { | 648 | + if ([[self failedRequests] count]+[[self finishedRequests] count] > 25) { |
| 649 | - GHFail(@"We got more than 100 delegate fail/finish calls - this shouldn't happen!"); | 649 | + GHFail(@"We got more than 25 delegate fail/finish calls - this shouldn't happen!"); |
| 650 | } | 650 | } |
| 651 | } | 651 | } |
| 652 | 652 | ||
| @@ -660,8 +660,8 @@ IMPORTANT | @@ -660,8 +660,8 @@ IMPORTANT | ||
| 660 | GHFail(@"A request that had already failed called its finish delegate method"); | 660 | GHFail(@"A request that had already failed called its finish delegate method"); |
| 661 | } | 661 | } |
| 662 | [[self finishedRequests] addObject:request]; | 662 | [[self finishedRequests] addObject:request]; |
| 663 | - if ([[self failedRequests] count]+[[self finishedRequests] count] > 100) { | 663 | + if ([[self failedRequests] count]+[[self finishedRequests] count] > 25) { |
| 664 | - GHFail(@"We got more than 100 delegate fail/finish calls - this shouldn't happen!"); | 664 | + GHFail(@"We got more than 25 delegate fail/finish calls - this shouldn't happen!"); |
| 665 | } | 665 | } |
| 666 | } | 666 | } |
| 667 | 667 |
-
Please register or login to post a comment