[Issue #161] [Issue #167] Replacing AFHTTPClient -cancelHTTPOperationsWithMethod:andURL: with -cancelAllHTTPOperationsWithMethod:path

This commit is contained in:
Mattt Thompson 2012-01-19 16:42:12 -08:00
parent e117c4e847
commit 735d86a79b
2 changed files with 8 additions and 6 deletions

View File

@ -294,12 +294,12 @@ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *paramete
- (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
/**
Cancels all operations in the HTTP client's operation queue that match the specified HTTP method and URL.
Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
@param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`.
@param url The URL to match for the cancelled requests.
@param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled.
@param url The path to match for the cancelled requests.
*/
- (void)cancelHTTPOperationsWithMethod:(NSString *)method andURL:(NSURL *)url;
- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
///---------------------------
/// @name Making HTTP Requests

View File

@ -326,13 +326,15 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
return operation;
}
#pragma mark -
- (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation {
[self.operationQueue addOperation:operation];
}
- (void)cancelHTTPOperationsWithMethod:(NSString *)method andURL:(NSURL *)url {
- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path {
for (AFHTTPRequestOperation *operation in [self.operationQueue operations]) {
if ([[[operation request] HTTPMethod] isEqualToString:method] && [[[operation request] URL] isEqual:url]) {
if ((!method || [method isEqualToString:[[operation request] HTTPMethod]]) && [path isEqualToString:[[[operation request] URL] path]]) {
[operation cancel];
}
}