Skip to content

Commit

Permalink
Adding AFHTTPClient -setDefaultCredential:
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Jan 4, 2013
1 parent 1d243f7 commit c613791
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 16 additions & 2 deletions AFNetworking/AFHTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -234,11 +236,23 @@ 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
///-------------------------------
Expand Down
3 changes: 3 additions & 0 deletions AFNetworking/AFHTTPClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -517,6 +518,8 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR
}

[operation setCompletionBlockWithSuccess:success failure:failure];

operation.credential = self.defaultCredential;

return operation;
}
Expand Down

0 comments on commit c613791

Please sign in to comment.