mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-30 05:35:40 +08:00
Ensure cancellation works with path patterns against baseURL's that include a path
This commit is contained in:
@@ -520,7 +520,8 @@ static NSString *RKMIMETypeFromAFHTTPClientParameterEncoding(AFHTTPClientParamet
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSURLRequest *request = [(RKObjectRequestOperation *)operation request];
|
NSURLRequest *request = [(RKObjectRequestOperation *)operation request];
|
||||||
if ((!methodName || [methodName isEqualToString:[request HTTPMethod]]) && [pathMatcher matchesPath:[[request URL] path] tokenizeQueryStrings:NO parsedArguments:nil]) {
|
NSString *pathAndQueryString = RKPathAndQueryStringFromURLRelativeToURL([request URL], self.baseURL);
|
||||||
|
if ((!methodName || [methodName isEqualToString:[request HTTPMethod]]) && [pathMatcher matchesPath:pathAndQueryString tokenizeQueryStrings:NO parsedArguments:nil]) {
|
||||||
[operation cancel];
|
[operation cancel];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,6 +282,16 @@
|
|||||||
expect([operation isCancelled]).to.equal(NO);
|
expect([operation isCancelled]).to.equal(NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)testCancellationByPathMatchForBaseURLWithPath
|
||||||
|
{
|
||||||
|
self.objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://localhost:4567/object_manager/"]];
|
||||||
|
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:4567/object_manager/1234/cancel"]];
|
||||||
|
RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:self.objectManager.responseDescriptors];
|
||||||
|
[_objectManager enqueueObjectRequestOperation:operation];
|
||||||
|
[_objectManager cancelAllObjectRequestOperationsWithMethod:RKRequestMethodGET matchingPathPattern:@":objectID/cancel"];
|
||||||
|
expect([operation isCancelled]).to.equal(YES);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)testShouldProperlyFireABatchOfOperations
|
- (void)testShouldProperlyFireABatchOfOperations
|
||||||
{
|
{
|
||||||
NSManagedObjectContext *managedObjectContext = [[RKTestFactory managedObjectStore] persistentStoreManagedObjectContext];
|
NSManagedObjectContext *managedObjectContext = [[RKTestFactory managedObjectStore] persistentStoreManagedObjectContext];
|
||||||
|
|||||||
Reference in New Issue
Block a user