diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index b8b8eee..901cb94 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -126,9 +126,16 @@ @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; -///-------------------------------- -/// @name Accessing URL Credentials -///-------------------------------- +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + + @discussion This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; /** The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 06f9ce4..17c98c9 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -145,6 +145,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat @dynamic inputStream; @synthesize outputStream = _outputStream; @synthesize credential = _credential; +@synthesize shouldUseCredentialStorage = _shouldUseCredentialStorage; @synthesize userInfo = _userInfo; @synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier; @synthesize uploadProgress = _uploadProgress; @@ -205,6 +206,8 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; self.outputStream = [NSOutputStream outputStreamToMemory]; @@ -573,6 +576,10 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge } } +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + - (NSInputStream *)connection:(NSURLConnection __unused *)connection needNewBodyStream:(NSURLRequest *)request {