From d10421e5117038111dca5058e8e1272bdc744978 Mon Sep 17 00:00:00 2001 From: Carson McDonald Date: Thu, 25 Jul 2013 11:34:50 -0400 Subject: [PATCH 1/2] Set async timeout to longer than request timeout --- Tests/AFHTTPRequestOperationTests.m | 2 ++ 1 file changed, 2 insertions(+) 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]]; From ef44858189fda20e0a7ca9948c388b358d6f4f0c Mon Sep 17 00:00:00 2001 From: Carson McDonald Date: Thu, 25 Jul 2013 11:35:50 -0400 Subject: [PATCH 2/2] Set error when cancel happens before start finishes --- AFNetworking/AFURLConnectionOperation.m | 5 +++++ 1 file changed, 5 insertions(+) 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]; } }