Merge pull request #743 from 0xced/NSURL-user-password

Use NSURL methods instead of CFURL functions
This commit is contained in:
Mattt Thompson 2013-01-20 21:08:48 -08:00
commit ba9185ded2

View file

@ -550,13 +550,13 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
if ([challenge previousFailureCount] == 0) {
NSURLCredential *credential = nil;
NSString *username = (__bridge_transfer NSString *)CFURLCopyUserName((__bridge CFURLRef)[self.request URL]);
NSString *password = (__bridge_transfer NSString *)CFURLCopyPassword((__bridge CFURLRef)[self.request URL]);
NSString *user = [[self.request URL] user];
NSString *password = [[self.request URL] password];
if (username && password) {
credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceNone];
} else if (username) {
credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:username];
if (user && password) {
credential = [NSURLCredential credentialWithUser:user password:password persistence:NSURLCredentialPersistenceNone];
} else if (user) {
credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:user];
} else {
credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
}