Permalink
Browse files

Adding AFHTTPClient -setDefaultCredential:

  • Loading branch information...
1 parent 1d243f7 commit c6137914fa9012e7beb11eed54cde70a8235f0cd @mattt mattt committed Jan 4, 2013
Showing with 19 additions and 2 deletions.
  1. +16 −2 AFNetworking/AFHTTPClient.h
  2. +3 −0 AFNetworking/AFHTTPClient.m
@@ -217,15 +217,17 @@ typedef enum {
@param header The HTTP header to set a default value for
@param value The value set as default for the specified header, or `nil
*/
-- (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
+- (void)setDefaultHeader:(NSString *)header
+ value:(NSString *)value;
/**
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
@param username The HTTP basic auth username
@param password The HTTP basic auth password
*/
-- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
+- (void)setAuthorizationHeaderWithUsername:(NSString *)username
+ password:(NSString *)password;
/**
Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
@@ -234,12 +236,24 @@ typedef enum {
*/
- (void)setAuthorizationHeaderWithToken:(NSString *)token;
+
/**
Clears any existing value for the "Authorization" HTTP header.
*/
- (void)clearAuthorizationHeader;
///-------------------------------
+/// @name Managing URL Credentials
+///-------------------------------
+
+/**
+ Set the default URL credential to be set for request operations.
+
+ @param credential The URL credential
+ */
+- (void)setDefaultCredential:(NSURLCredential *)credential;
+
+///-------------------------------
/// @name Creating Request Objects
///-------------------------------
@@ -179,6 +179,7 @@ @interface AFHTTPClient ()
@property (readwrite, nonatomic) NSURL *baseURL;
@property (readwrite, nonatomic) NSMutableArray *registeredHTTPOperationClassNames;
@property (readwrite, nonatomic) NSMutableDictionary *defaultHeaders;
+@property (readwrite, nonatomic) NSURLCredential *defaultCredential;
@property (readwrite, nonatomic) NSOperationQueue *operationQueue;
#ifdef _SYSTEMCONFIGURATION_H
@property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability;
@@ -517,6 +518,8 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR
}
[operation setCompletionBlockWithSuccess:success failure:failure];
+
+ operation.credential = self.defaultCredential;
return operation;
}

0 comments on commit c613791

Please sign in to comment.