Adding credential property to AFURLConnectionOperation

This commit is contained in:
Mattt Thompson 2013-01-04 12:41:25 -08:00
parent 121ef7afa8
commit 1d243f7794
2 changed files with 19 additions and 2 deletions

View file

@ -124,6 +124,18 @@
*/ */
@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; @property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding;
///--------------------------------
/// @name Accessing URL Credentials
///--------------------------------
/**
The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`.
@discussion This will be overridden by any shared credentials that exist for the username or password of the request URL, if present.
*/
@property (nonatomic, strong) NSURLCredential *credential;
///------------------------ ///------------------------
/// @name Accessing Streams /// @name Accessing Streams
///------------------------ ///------------------------

View file

@ -144,6 +144,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
@synthesize totalBytesRead = _totalBytesRead; @synthesize totalBytesRead = _totalBytesRead;
@dynamic inputStream; @dynamic inputStream;
@synthesize outputStream = _outputStream; @synthesize outputStream = _outputStream;
@synthesize credential = _credential;
@synthesize userInfo = _userInfo; @synthesize userInfo = _userInfo;
@synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier; @synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier;
@synthesize uploadProgress = _uploadProgress; @synthesize uploadProgress = _uploadProgress;
@ -557,6 +558,10 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]]; credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
} }
if (!credential) {
credential = self.credential;
}
if (credential) { if (credential) {
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
} else { } else {