From e436305b338a234bcea95b19739a9d50ff713a12 Mon Sep 17 00:00:00 2001 From: Anurodh Pokharel Date: Fri, 19 Jun 2015 14:49:58 -0400 Subject: [PATCH 1/6] Added support for JSON payloads. Added support for HTTP PATCH. Oauth client will now work with salesforce. --- Sources/OAuth2Client/NXOAuth2Client.h | 2 - Sources/OAuth2Client/NXOAuth2Client.m | 12 ----- Sources/OAuth2Client/NXOAuth2Connection.h | 2 +- Sources/OAuth2Client/NXOAuth2Connection.m | 25 +++++++--- Sources/OAuth2Client/NXOAuth2Request.h | 14 ++++++ Sources/OAuth2Client/NXOAuth2Request.m | 59 ++++++++++++++++++++--- 6 files changed, 85 insertions(+), 29 deletions(-) diff --git a/Sources/OAuth2Client/NXOAuth2Client.h b/Sources/OAuth2Client/NXOAuth2Client.h index 64c1f286..e6771654 100644 --- a/Sources/OAuth2Client/NXOAuth2Client.h +++ b/Sources/OAuth2Client/NXOAuth2Client.h @@ -76,7 +76,6 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh; @property (nonatomic, strong) NXOAuth2AccessToken *accessToken; @property (nonatomic, unsafe_unretained) NSObject* delegate; -@property (nonatomic, readonly) NXOAuth2Connection *authConnection; /*! * If set to NO, the access token is not stored any keychain, will be removed if it was. @@ -144,7 +143,6 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh; #pragma mark Public - (void)requestAccess; -- (void)requestAccessAndRetryConnection:(NXOAuth2Connection *)retryConnection; - (void)refreshAccessToken; - (void)refreshAccessTokenAndRetryConnection:(NXOAuth2Connection *)retryConnection; diff --git a/Sources/OAuth2Client/NXOAuth2Client.m b/Sources/OAuth2Client/NXOAuth2Client.m index 41b4a903..d681776a 100644 --- a/Sources/OAuth2Client/NXOAuth2Client.m +++ b/Sources/OAuth2Client/NXOAuth2Client.m @@ -122,7 +122,6 @@ - (void)dealloc; @synthesize desiredScope, userAgent; @synthesize delegate, persistent, accessToken, authenticating; @synthesize additionalAuthenticationParameters; -@synthesize authConnection = authConnection; - (void)setAdditionalAuthenticationParameters:(NSDictionary *)value; { @@ -233,19 +232,8 @@ - (void)setDesiredScope:(NSSet *)aDesiredScope; #pragma mark Flow - (void)requestAccess; -{ - [self requestAccessAndRetryConnection:nil]; -} - -- (void)requestAccessAndRetryConnection:(NXOAuth2Connection *)retryConnection { if (!self.accessToken) { - - if (retryConnection) { - if (!waitingConnections) waitingConnections = [[NSMutableArray alloc] init]; - [waitingConnections addObject:retryConnection]; - } - [delegate oauthClientNeedsAuthentication:self]; } } diff --git a/Sources/OAuth2Client/NXOAuth2Connection.h b/Sources/OAuth2Client/NXOAuth2Connection.h index c29feb54..f56a20f2 100644 --- a/Sources/OAuth2Client/NXOAuth2Connection.h +++ b/Sources/OAuth2Client/NXOAuth2Connection.h @@ -40,7 +40,7 @@ #define NXOAuth2ConnectionDebug 0 #endif - +FOUNDATION_EXPORT NSString * const jsonContentType; extern NSString * const NXOAuth2ConnectionDidStartNotification; extern NSString * const NXOAuth2ConnectionDidEndNotification; diff --git a/Sources/OAuth2Client/NXOAuth2Connection.m b/Sources/OAuth2Client/NXOAuth2Connection.m index fb2e2114..0496139e 100644 --- a/Sources/OAuth2Client/NXOAuth2Connection.m +++ b/Sources/OAuth2Client/NXOAuth2Connection.m @@ -25,6 +25,7 @@ @interface NXOAuth2Client (Private) - (void)removeConnectionFromWaitingQueue:(NXOAuth2Connection *)connection; @end +NSString * const jsonContentType = @"application/json" ; NSString * const NXOAuth2ConnectionDidStartNotification = @"NXOAuth2ConnectionDidStartNotification"; NSString * const NXOAuth2ConnectionDidEndNotification = @"NXOAuth2ConnectionDidEndNotification"; @@ -222,7 +223,9 @@ - (void)applyParameters:(NSDictionary *)parameters onRequest:(NSMutableURLReques NSString *httpMethod = [aRequest HTTPMethod]; if ([httpMethod caseInsensitiveCompare:@"POST"] != NSOrderedSame - && [httpMethod caseInsensitiveCompare:@"PUT"] != NSOrderedSame) { + && [httpMethod caseInsensitiveCompare:@"PUT"] != NSOrderedSame + && [httpMethod caseInsensitiveCompare:@"PATCH"] != NSOrderedSame + ) { aRequest.URL = [aRequest.URL nxoauth2_URLByAddingParameters:parameters]; @@ -243,7 +246,16 @@ - (void)applyParameters:(NSDictionary *)parameters onRequest:(NSMutableURLReques [aRequest setHTTPBodyStream:postBodyStream]; - } else if ([contentType isEqualToString:@"application/x-www-form-urlencoded"]) { + } + else if([contentType isEqualToString:jsonContentType]){ + NSError *error; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]; + if(!error) + { + [aRequest setHTTPBody:jsonData]; + } + } + else if ([contentType isEqualToString:@"application/x-www-form-urlencoded"]) { // sends the POST/PUT request as application/x-www-form-urlencoded @@ -415,13 +427,12 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespon } } } - - if (client.authConnection != self && authenticateHeader && client.accessToken.refreshToken != nil && [authenticateHeader rangeOfString:@"expired_token"].location != NSNotFound) { + if (self.statusCode == 401 + && client.accessToken.refreshToken != nil + && authenticateHeader + && [authenticateHeader rangeOfString:@"expired_token"].location != NSNotFound) { [self cancel]; [client refreshAccessTokenAndRetryConnection:self]; - } else if (client.authConnection != self && authenticateHeader && client) { - [self cancel]; - [client requestAccessAndRetryConnection:self]; } else { if ([delegate respondsToSelector:@selector(oauthConnection:didReceiveData:)]) { [delegate oauthConnection:self didReceiveData:data]; // inform the delegate that we start with empty data diff --git a/Sources/OAuth2Client/NXOAuth2Request.h b/Sources/OAuth2Client/NXOAuth2Request.h index aa601af5..22f3222e 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.h +++ b/Sources/OAuth2Client/NXOAuth2Request.h @@ -22,6 +22,7 @@ NSDictionary *parameters; NSURL *resource; NSString *requestMethod; + NSString *requestContentType; NXOAuth2Account *account; NXOAuth2Connection *connection; NXOAuth2Request *me; @@ -37,6 +38,18 @@ sendProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler; +/** + Content type nil will use form data. + */ ++ (void)performMethod:(NSString *)method + onResource:(NSURL *)resource + withContentType:(NSString *) contentType + usingParameters:(NSDictionary *)parameters + withAccount:(NXOAuth2Account *)account + sendProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler + responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler; + + #pragma mark Lifecycle @@ -50,6 +63,7 @@ @property (nonatomic, strong, readwrite) NXOAuth2Account *account; @property (nonatomic, strong, readwrite) NSString *requestMethod; +@property (nonatomic, strong, readwrite) NSString *requestContentType; @property (nonatomic, strong, readwrite) NSURL *resource; @property (nonatomic, strong, readwrite) NSDictionary *parameters; diff --git a/Sources/OAuth2Client/NXOAuth2Request.m b/Sources/OAuth2Client/NXOAuth2Request.m index ad8564bd..e9ff8619 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.m +++ b/Sources/OAuth2Client/NXOAuth2Request.m @@ -22,6 +22,7 @@ #import "NXOAuth2Request.h" + @interface NXOAuth2Request () @property (nonatomic, strong, readwrite) NXOAuth2Connection *connection; @property (nonatomic, strong, readwrite) NXOAuth2Request *me; @@ -49,6 +50,23 @@ + (void)performMethod:(NSString *)aMethod } + ++ (void)performMethod:(NSString *)aMethod + onResource:(NSURL *)aResource + withContentType:(NSString *) aContentType + usingParameters:(NSDictionary *)someParameters + withAccount:(NXOAuth2Account *)anAccount + sendProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler + responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler; +{ + NXOAuth2Request *request = [[NXOAuth2Request alloc] initWithResource:aResource + method:aMethod + contentType:aContentType + parameters:someParameters]; + request.account = anAccount; + [request performRequestWithSendingProgressHandler:progressHandler responseHandler:responseHandler]; +} + #pragma mark Lifecycle - (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod parameters:(NSDictionary *)someParameters; @@ -63,11 +81,24 @@ - (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod p } +- (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod contentType:(NSString *) aContentType parameters:(NSDictionary *)someParameters +{ + self = [super init]; + if (self) { + resource = aResource; + parameters = someParameters; + requestMethod = aMethod; + requestContentType= aContentType; + } + return self; +} + #pragma mark Accessors @synthesize parameters; @synthesize resource; @synthesize requestMethod; +@synthesize requestContentType; @synthesize account; @synthesize connection; @synthesize me; @@ -105,6 +136,11 @@ - (void)performRequestWithSendingProgressHandler:(NXOAuth2ConnectionSendingProgr NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.resource]; [request setHTTPMethod:self.requestMethod]; + if(self.requestContentType) + { + [request setValue:self.requestContentType forHTTPHeaderField:@"Content-Type"]; + } + self.connection = [[NXOAuth2Connection alloc] initWithRequest:request requestParameters:self.parameters oauthClient:self.account.oauthClient @@ -160,14 +196,23 @@ - (void)applyParameters:(NSDictionary *)someParameters onRequest:(NSMutableURLRe if (![@[@"POST",@"PUT",@"PATCH"] containsObject: [httpMethod uppercaseString]]) { aRequest.URL = [aRequest.URL nxoauth2_URLByAddingParameters:someParameters]; } else { - NSInputStream *postBodyStream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameters]; - - NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", [(NXOAuth2PostBodyStream *)postBodyStream boundary]]; - NSString *contentLength = [NSString stringWithFormat:@"%llu", [(NXOAuth2PostBodyStream *)postBodyStream length]]; - [aRequest setValue:contentType forHTTPHeaderField:@"Content-Type"]; - [aRequest setValue:contentLength forHTTPHeaderField:@"Content-Length"]; + if([requestContentType isEqualToString:jsonContentType]){ + NSError *error; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]; + if(!error) + { + [aRequest setHTTPBody:jsonData]; + } + [aRequest setValue:requestContentType forHTTPHeaderField:@"Content-Type"]; + } else { + NSInputStream *postBodyStream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameters]; + NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", [(NXOAuth2PostBodyStream *)postBodyStream boundary]]; + [aRequest setValue:contentType forHTTPHeaderField:@"Content-Type"]; + NSString *contentLength = [NSString stringWithFormat:@"%llu", [(NXOAuth2PostBodyStream *)postBodyStream length]]; + [aRequest setValue:contentLength forHTTPHeaderField:@"Content-Length"]; + [aRequest setHTTPBodyStream:postBodyStream]; + } - [aRequest setHTTPBodyStream:postBodyStream]; } } From 37e94efd89d615acc5ce47c053e880a07a7ab972 Mon Sep 17 00:00:00 2001 From: Adam Kornafeld Date: Mon, 6 Jul 2015 12:38:40 -0400 Subject: [PATCH 2/6] PT-733 Turn off URL caching --- Sources/OAuth2Client/NXOAuth2Connection.m | 4 ++++ Sources/OAuth2Client/NXOAuth2Request.m | 1 + 2 files changed, 5 insertions(+) diff --git a/Sources/OAuth2Client/NXOAuth2Connection.m b/Sources/OAuth2Client/NXOAuth2Connection.m index 0496139e..df96016e 100644 --- a/Sources/OAuth2Client/NXOAuth2Connection.m +++ b/Sources/OAuth2Client/NXOAuth2Connection.m @@ -599,4 +599,8 @@ - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallen } } +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { + return nil; +} + @end diff --git a/Sources/OAuth2Client/NXOAuth2Request.m b/Sources/OAuth2Client/NXOAuth2Request.m index e9ff8619..fc65963d 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.m +++ b/Sources/OAuth2Client/NXOAuth2Request.m @@ -136,6 +136,7 @@ - (void)performRequestWithSendingProgressHandler:(NXOAuth2ConnectionSendingProgr NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.resource]; [request setHTTPMethod:self.requestMethod]; + [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; if(self.requestContentType) { [request setValue:self.requestContentType forHTTPHeaderField:@"Content-Type"]; From c7835764768643b3934ec6a9360ad57319074efa Mon Sep 17 00:00:00 2001 From: Adam Kornafeld Date: Fri, 18 Mar 2016 13:22:27 -0400 Subject: [PATCH 3/6] PT-1271 Add property 'activeAccountType' Select the active pendingOAuthClient to handle URL redirects --- Sources/OAuth2Client/NXOAuth2AccountStore.h | 1 + Sources/OAuth2Client/NXOAuth2AccountStore.m | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.h b/Sources/OAuth2Client/NXOAuth2AccountStore.h index 48bcea01..778a0feb 100644 --- a/Sources/OAuth2Client/NXOAuth2AccountStore.h +++ b/Sources/OAuth2Client/NXOAuth2AccountStore.h @@ -84,6 +84,7 @@ typedef void(^NXOAuth2PreparedAuthorizationURLHandler)(NSURL *preparedURL); @property(nonatomic, strong) NSString *keychainAccessGroup; @property(nonatomic, strong) NSString *keychainServiceName; @property(nonatomic, strong, readonly) NSArray *accounts; +@property(nonatomic, copy) NSString *activeAccountType; - (NSArray *)accountsWithAccountType:(NSString *)accountType; - (NXOAuth2Account *)accountWithIdentifier:(NSString *)identifier; diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.m b/Sources/OAuth2Client/NXOAuth2AccountStore.m index b14cbfcd..37a80ad1 100644 --- a/Sources/OAuth2Client/NXOAuth2AccountStore.m +++ b/Sources/OAuth2Client/NXOAuth2AccountStore.m @@ -407,7 +407,7 @@ - (BOOL)handleRedirectURL:(NSURL *)aURL; for (NSString *accountType in accountTypes) { NXOAuth2Client *client = [self pendingOAuthClientForAccountType:accountType]; - if ([client openRedirectURL:fixedRedirectURL]) { + if ([self.activeAccountType isEqualToString:accountType] && [client openRedirectURL:fixedRedirectURL]) { return YES; } } From 54e3eb756db1f906928a1ec93a279ee6e801db1f Mon Sep 17 00:00:00 2001 From: Adam Kornafeld Date: Fri, 22 Apr 2016 09:53:16 -0400 Subject: [PATCH 4/6] [DEV_TOOLS] Fix static analyzer warning --- Sources/OAuth2Client/NXOAuth2AccountStore.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.m b/Sources/OAuth2Client/NXOAuth2AccountStore.m index 37a80ad1..27f806bc 100644 --- a/Sources/OAuth2Client/NXOAuth2AccountStore.m +++ b/Sources/OAuth2Client/NXOAuth2AccountStore.m @@ -544,13 +544,15 @@ - (void)oauthClientDidRefreshAccessToken:(NXOAuth2Client *)client } } - foundAccount.accessToken = client.accessToken; - NSDictionary *userInfo = [NSDictionary dictionaryWithObject: foundAccount - forKey: NXOAuth2AccountStoreNewAccountUserInfoKey]; - - [[NSNotificationCenter defaultCenter] postNotificationName:NXOAuth2AccountStoreAccountsDidChangeNotification - object:self - userInfo:userInfo]; + if (foundAccount) { + foundAccount.accessToken = client.accessToken; + NSDictionary *userInfo = [NSDictionary dictionaryWithObject: foundAccount + forKey: NXOAuth2AccountStoreNewAccountUserInfoKey]; + + [[NSNotificationCenter defaultCenter] postNotificationName:NXOAuth2AccountStoreAccountsDidChangeNotification + object:self + userInfo:userInfo]; + } } - (void)addAccount:(NXOAuth2Account *)account; From 33bd21c147ccbfb9e78cee5ce5090ba76cf662d6 Mon Sep 17 00:00:00 2001 From: Anurodh Pokharel Date: Mon, 22 Aug 2016 16:21:58 -0400 Subject: [PATCH 5/6] removed content type --- Sources/OAuth2Client/NXOAuth2Request.h | 3 --- Sources/OAuth2Client/NXOAuth2Request.m | 17 ----------------- 2 files changed, 20 deletions(-) diff --git a/Sources/OAuth2Client/NXOAuth2Request.h b/Sources/OAuth2Client/NXOAuth2Request.h index ba9de5ef..f982cf91 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.h +++ b/Sources/OAuth2Client/NXOAuth2Request.h @@ -39,9 +39,6 @@ responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler; -/** - Content type nil will use form data. - */ + (void)performMethod:(NSString *)method onResource:(NSURL *)resource usingParameters:(NSDictionary *)parameters diff --git a/Sources/OAuth2Client/NXOAuth2Request.m b/Sources/OAuth2Client/NXOAuth2Request.m index 7c651240..70fd8e99 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.m +++ b/Sources/OAuth2Client/NXOAuth2Request.m @@ -69,23 +69,6 @@ + (void)performMethod:(NSString *)aMethod } - -+ (void)performMethod:(NSString *)aMethod - onResource:(NSURL *)aResource - withContentType:(NSString *) aContentType - usingParameters:(NSDictionary *)someParameters - withAccount:(NXOAuth2Account *)anAccount - sendProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)progressHandler - responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler; -{ - NXOAuth2Request *request = [[NXOAuth2Request alloc] initWithResource:aResource - method:aMethod - contentType:aContentType - parameters:someParameters]; - request.account = anAccount; - [request performRequestWithSendingProgressHandler:progressHandler responseHandler:responseHandler]; -} - #pragma mark Lifecycle - (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod parameters:(NSDictionary *)someParameters; From 916b5d5c9aef4fe16b6c560ec6643a801ba77ee1 Mon Sep 17 00:00:00 2001 From: Anurodh Pokharel Date: Mon, 22 Aug 2016 16:39:34 -0400 Subject: [PATCH 6/6] removed content type specific code --- Sources/OAuth2Client/NXOAuth2Request.h | 1 - Sources/OAuth2Client/NXOAuth2Request.m | 28 ++++++++------------------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Sources/OAuth2Client/NXOAuth2Request.h b/Sources/OAuth2Client/NXOAuth2Request.h index f982cf91..96d9b003 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.h +++ b/Sources/OAuth2Client/NXOAuth2Request.h @@ -22,7 +22,6 @@ NSDictionary *parameters; NSURL *resource; NSString *requestMethod; - NSString *requestContentType; NXOAuth2Account *account; NXOAuth2Connection *connection; NXOAuth2Request *me; diff --git a/Sources/OAuth2Client/NXOAuth2Request.m b/Sources/OAuth2Client/NXOAuth2Request.m index 70fd8e99..7c6c2d59 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.m +++ b/Sources/OAuth2Client/NXOAuth2Request.m @@ -90,7 +90,6 @@ - (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod c resource = aResource; parameters = someParameters; requestMethod = aMethod; - requestContentType= aContentType; } return self; } @@ -100,7 +99,6 @@ - (instancetype)initWithResource:(NSURL *)aResource method:(NSString *)aMethod c @synthesize parameters; @synthesize resource; @synthesize requestMethod; -@synthesize requestContentType; @synthesize account; @synthesize connection; @synthesize me; @@ -202,25 +200,15 @@ - (void)applyParameters:(NSDictionary *)someParameters onRequest:(NSMutableURLRe NSString *httpMethod = [aRequest HTTPMethod]; if (![@[@"POST",@"PUT",@"PATCH"] containsObject: [httpMethod uppercaseString]]) { aRequest.URL = [aRequest.URL nxoauth2_URLByAddingParameters:someParameters]; - } else { - if([requestContentType isEqualToString:jsonContentType]){ - NSError *error; - NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]; - if(!error) - { - [aRequest setHTTPBody:jsonData]; - } - [aRequest setValue:requestContentType forHTTPHeaderField:@"Content-Type"]; - } else { - NSInputStream *postBodyStream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameters]; - NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", [(NXOAuth2PostBodyStream *)postBodyStream boundary]]; - [aRequest setValue:contentType forHTTPHeaderField:@"Content-Type"]; - NSString *contentLength = [NSString stringWithFormat:@"%llu", [(NXOAuth2PostBodyStream *)postBodyStream length]]; - [aRequest setValue:contentLength forHTTPHeaderField:@"Content-Length"]; - [aRequest setHTTPBodyStream:postBodyStream]; - } - + } else { + NSInputStream *postBodyStream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameters]; + NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", [(NXOAuth2PostBodyStream *)postBodyStream boundary]]; + [aRequest setValue:contentType forHTTPHeaderField:@"Content-Type"]; + NSString *contentLength = [NSString stringWithFormat:@"%llu", [(NXOAuth2PostBodyStream *)postBodyStream length]]; + [aRequest setValue:contentLength forHTTPHeaderField:@"Content-Length"]; + [aRequest setHTTPBodyStream:postBodyStream]; } + } - (void)applyHeaders:(NSDictionary *)someHeaders onRequest:(NSMutableURLRequest *)aRequest;