|
@@ -245,7 +245,8 @@ NSOperationQueue *taskQueue;
|
245
|
245
|
}
|
246
|
246
|
|
247
|
247
|
__block NSURLSessionDataTask * task = [session dataTaskWithRequest:req];
|
248
|
|
- [taskTable setObject:task forKey:taskId];
|
|
248
|
+
|
|
249
|
+ [taskTable setObject:@{ @"session" : task, @"isCancelled" : @NO } forKey:taskId];
|
249
|
250
|
[task resume];
|
250
|
251
|
|
251
|
252
|
// network status indicator
|
|
@@ -503,6 +504,11 @@ NSOperationQueue *taskQueue;
|
503
|
504
|
{
|
504
|
505
|
errMsg = [error localizedDescription];
|
505
|
506
|
}
|
|
507
|
+ NSDictionary * taskSession = [taskTable objectForKey:taskId];
|
|
508
|
+ BOOL isCancelled = [taskSession valueForKey:@"isCancelled"];
|
|
509
|
+ if(isCancelled) {
|
|
510
|
+ errMsg = @"task cancelled";
|
|
511
|
+ }
|
506
|
512
|
|
507
|
513
|
if(respFile == YES)
|
508
|
514
|
{
|
|
@@ -583,9 +589,16 @@ NSOperationQueue *taskQueue;
|
583
|
589
|
|
584
|
590
|
+ (void) cancelRequest:(NSString *)taskId
|
585
|
591
|
{
|
586
|
|
- NSURLSessionDataTask * task = [taskTable objectForKey:taskId];
|
587
|
|
- if(task != nil && task.state == NSURLSessionTaskStateRunning)
|
588
|
|
- [task cancel];
|
|
592
|
+ NSDictionary * task = [taskTable objectForKey:taskId];
|
|
593
|
+
|
|
594
|
+ if(task != nil) {
|
|
595
|
+ NSURLSessionDataTask * session = [task objectForKey:@"session"];
|
|
596
|
+ if(session.state == NSURLSessionTaskStateRunning) {
|
|
597
|
+ [task setValue:@NO forKey:@"isCancelled"];
|
|
598
|
+ [session cancel];
|
|
599
|
+ }
|
|
600
|
+ }
|
|
601
|
+
|
589
|
602
|
}
|
590
|
603
|
|
591
|
604
|
|