[Issue #719] Adding shouldUseCredentialStorage property to AFURLConnectionOperation /thanks Xihe Yu

This commit is contained in:
Mattt Thompson 2013-01-06 20:44:48 -08:00
parent 1e7c45c191
commit 9aeb38649b
2 changed files with 17 additions and 3 deletions

View file

@ -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:`.

View file

@ -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;
@ -206,6 +207,8 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
self.request = urlRequest;
self.shouldUseCredentialStorage = YES;
self.outputStream = [NSOutputStream outputStreamToMemory];
self.state = AFOperationReadyState;
@ -573,6 +576,10 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
}
}
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection {
return self.shouldUseCredentialStorage;
}
- (NSInputStream *)connection:(NSURLConnection __unused *)connection
needNewBodyStream:(NSURLRequest *)request
{