Ben Copsey

Refactor session credentials storage to store multiple sets of credentials, and …

…perform some checking to see if we should apply the credentials
Tweak test
... ... @@ -388,8 +388,8 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
#pragma mark http authentication stuff
// Apply credentials to this request
- (BOOL)applyCredentials:(NSMutableDictionary *)newCredentials;
- (BOOL)applyProxyCredentials:(NSMutableDictionary *)newCredentials;
- (BOOL)applyCredentials:(NSDictionary *)newCredentials;
- (BOOL)applyProxyCredentials:(NSDictionary *)newCredentials;
// Attempt to obtain credentials for this request from the URL, username and password or keychain
- (NSMutableDictionary *)findCredentials;
... ... @@ -414,17 +414,25 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
- (void)handleStreamComplete;
- (void)handleStreamError;
#pragma mark managing the session
# pragma mark session credentials
+ (NSMutableArray *)sessionProxyCredentialsStore;
+ (NSMutableArray *)sessionCredentialsStore;
+ (void)storeProxyAuthenticationCredentialsInSessionStore:(NSDictionary *)credentials;
+ (void)storeAuthenticationCredentialsInSessionStore:(NSDictionary *)credentials;
+ (void)removeProxyAuthenticationCredentialsFromSessionStore:(NSDictionary *)credentials;
+ (void)removeAuthenticationCredentialsFromSessionStore:(NSDictionary *)credentials;
- (NSDictionary *)findSessionProxyAuthenticationCredentials;
- (NSDictionary *)findSessionAuthenticationCredentials;
+ (void)setSessionCredentials:(NSMutableDictionary *)newCredentials;
+ (void)setSessionAuthentication:(CFHTTPAuthenticationRef)newAuthentication;
+ (void)setSessionProxyCredentials:(NSMutableDictionary *)newCredentials;
+ (void)setSessionProxyAuthentication:(CFHTTPAuthenticationRef)newAuthentication;
#pragma mark keychain storage
// Save credentials for this request to the keychain
- (void)saveCredentialsToKeychain:(NSMutableDictionary *)newCredentials;
- (void)saveCredentialsToKeychain:(NSDictionary *)newCredentials;
// Save credentials to the keychain
+ (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
[self setFinishedRequests:[[[NSMutableArray alloc] init] autorelease]];
[self setImmediateCancelQueue:[[[NSOperationQueue alloc] init] autorelease]];
int i;
for (i=0; i<100; i++) {
for (i=0; i<25; i++) {
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request setDelegate:self];
[request setDidFailSelector:@selector(immediateCancelFail:)];
... ... @@ -645,8 +645,8 @@ IMPORTANT
GHFail(@"A request that had already finished called its fail delegate method");
}
[[self failedRequests] addObject:request];
if ([[self failedRequests] count]+[[self finishedRequests] count] > 100) {
GHFail(@"We got more than 100 delegate fail/finish calls - this shouldn't happen!");
if ([[self failedRequests] count]+[[self finishedRequests] count] > 25) {
GHFail(@"We got more than 25 delegate fail/finish calls - this shouldn't happen!");
}
}
... ... @@ -660,8 +660,8 @@ IMPORTANT
GHFail(@"A request that had already failed called its finish delegate method");
}
[[self finishedRequests] addObject:request];
if ([[self failedRequests] count]+[[self finishedRequests] count] > 100) {
GHFail(@"We got more than 100 delegate fail/finish calls - this shouldn't happen!");
if ([[self failedRequests] count]+[[self finishedRequests] count] > 25) {
GHFail(@"We got more than 25 delegate fail/finish calls - this shouldn't happen!");
}
}
... ...