diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 62fa457..6c49bb8 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -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 diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index e7eaa7e..0627036 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -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]; } }