From 9aeb38649b21aba03d2e05aa4f4a25fa73d1815d Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Sun, 6 Jan 2013 20:44:48 -0800 Subject: [PATCH] [Issue #719] Adding shouldUseCredentialStorage property to AFURLConnectionOperation /thanks Xihe Yu --- AFNetworking/AFURLConnectionOperation.h | 13 ++++++++++--- AFNetworking/AFURLConnectionOperation.m | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) 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 {