diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 58c305e..4498513 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -528,6 +528,11 @@ static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { }); if ([self isCancelled]) { + NSDictionary *userInfo = nil; + if ([self.request URL]) { + userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + } + self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; [self finish]; } } diff --git a/Tests/AFHTTPRequestOperationTests.m b/Tests/AFHTTPRequestOperationTests.m index b1ffa08..20fc05c 100644 --- a/Tests/AFHTTPRequestOperationTests.m +++ b/Tests/AFHTTPRequestOperationTests.m @@ -76,6 +76,8 @@ } - (void)testThatCancellationOfRequestOperationInvokesFailureCompletionBlock { + [Expecta setAsynchronousTestTimeout:10.0]; + __block NSError *blockError = nil; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/delay/5" relativeToURL:self.baseURL]];