Ben Copsey

Change things so that you can still send a basic auth header on your very first …

…request, as long as you explictly set authenticationScheme to kCFHTTPAuthenticationSchemeBasic
... ... @@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.8-53 2011-02-06";
NSString *ASIHTTPRequestVersion = @"v1.8-56 2011-02-06";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -953,8 +953,8 @@ static NSOperationQueue *sharedQueue = nil;
// Are any credentials set on this request that might be used for basic authentication?
if ([self username] && [self password] && ![self domain]) {
// If we have stored credentials, is this server asking for basic authentication?
if ((CFStringRef)[credentials objectForKey:@"AuthenticationScheme"] == kCFHTTPAuthenticationSchemeBasic) {
// If we know this request should use Basic auth, we'll add an Authorization header with basic credentials
if ([[self authenticationScheme] isEqualToString:(NSString *)kCFHTTPAuthenticationSchemeBasic]) {
[self addBasicAuthenticationHeaderWithUsername:[self username] andPassword:[self password]];
}
}
... ...
... ... @@ -1083,7 +1083,7 @@
[request setUseSessionPersistence:YES];
[request startSynchronous];
success = [request authenticationRetryCount] == 0;
GHAssertTrue(success,@"Didn't supply credentials before being asked for them when talking to the same server with shouldPresentCredentialsBeforeChallenge == YES");
GHAssertTrue(success,@"Didn't supply credentials before being asked for them when talking to the same server with shouldPresentCredentialsBeforeChallenge == YES");
// Ensure credentials stored in the session were not presented to the server before it asked for them
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
... ... @@ -1095,15 +1095,26 @@
[ASIHTTPRequest clearSession];
// Test credentials set on the request are sent before the server asks for them
// Test credentials set on the request are not sent before the server asks for them unless they are cached credentials from a previous request to this server
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseSessionPersistence:NO];
[request setUsername:@"secret_username"];
[request setPassword:@"secret_password"];
[request setShouldPresentCredentialsBeforeChallenge:YES];
[request startSynchronous];
BOOL fail = [request authenticationRetryCount] == 0;
GHAssertFalse(fail,@"Sent Basic credentials even though request did not have kCFHTTPAuthenticationSchemeBasic set as authenticationScheme.");
// Test basic credentials set on the request are sent before the server asks for them if we've explictly set the authentication scheme to basic
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseSessionPersistence:NO];
[request setUsername:@"secret_username"];
[request setPassword:@"secret_password"];
[request setShouldPresentCredentialsBeforeChallenge:YES];
[request setAuthenticationScheme:(NSString *)kCFHTTPAuthenticationSchemeBasic];
[request startSynchronous];
success = [request authenticationRetryCount] == 0;
GHAssertTrue(success,@"Didn't supply credentials before being asked for them, even though they were set on the request and shouldPresentCredentialsBeforeChallenge == YES");
GHAssertTrue(success,@"Didn't supply credentials before being asked for them, even though they were set on the request and shouldPresentCredentialsBeforeChallenge == YES");
// Test credentials set on the request aren't sent before the server asks for them
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
... ...
This diff was suppressed by a .gitattributes entry.