Permalink
Browse files

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

Use NSURL methods instead of CFURL functions
  • Loading branch information...
2 parents c79a2c8 + 7abc978 commit ba9185ded233850ac7863a624fab182a8a5836b2 @mattt mattt committed Jan 21, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 AFNetworking/AFURLConnectionOperation.m
@@ -550,13 +550,13 @@ - (void)connection:(NSURLConnection *)connection
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]];
}

0 comments on commit ba9185d

Please sign in to comment.