|
|
|
|
82
|
NSMutableArray * redirects;
|
82
|
NSMutableArray * redirects;
|
83
|
ResponseFormat responseFormat;
|
83
|
ResponseFormat responseFormat;
|
84
|
BOOL * followRedirect;
|
84
|
BOOL * followRedirect;
|
|
|
85
|
+ BOOL backgroundTask;
|
85
|
}
|
86
|
}
|
86
|
|
87
|
|
87
|
@end
|
88
|
@end
|
|
|
|
|
168
|
self.expectedBytes = 0;
|
169
|
self.expectedBytes = 0;
|
169
|
self.receivedBytes = 0;
|
170
|
self.receivedBytes = 0;
|
170
|
self.options = options;
|
171
|
self.options = options;
|
|
|
172
|
+
|
|
|
173
|
+ backgroundTask = [options valueForKey:@"IOSBackgroundTask"] == nil ? NO : [[options valueForKey:@"IOSBackgroundTask"] boolValue];
|
171
|
followRedirect = [options valueForKey:@"followRedirect"] == nil ? YES : [[options valueForKey:@"followRedirect"] boolValue];
|
174
|
followRedirect = [options valueForKey:@"followRedirect"] == nil ? YES : [[options valueForKey:@"followRedirect"] boolValue];
|
172
|
isIncrement = [options valueForKey:@"increment"] == nil ? NO : [[options valueForKey:@"increment"] boolValue];
|
175
|
isIncrement = [options valueForKey:@"increment"] == nil ? NO : [[options valueForKey:@"increment"] boolValue];
|
173
|
redirects = [[NSMutableArray alloc] init];
|
176
|
redirects = [[NSMutableArray alloc] init];
|
|
|
|
|
192
|
|
195
|
|
193
|
// the session trust any SSL certification
|
196
|
// the session trust any SSL certification
|
194
|
NSURLSessionConfiguration *defaultConfigObject;
|
197
|
NSURLSessionConfiguration *defaultConfigObject;
|
195
|
- if(!followRedirect)
|
|
|
196
|
- {
|
|
|
197
|
- defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
|
|
|
198
|
- }
|
|
|
199
|
- else
|
|
|
|
|
198
|
+
|
|
|
199
|
+ defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
|
|
|
200
|
+
|
|
|
201
|
+ if(backgroundTask)
|
200
|
{
|
202
|
{
|
201
|
- NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:taskId];
|
|
|
|
|
203
|
+ defaultConfigObject = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:taskId];
|
202
|
}
|
204
|
}
|
203
|
|
205
|
|
204
|
// set request timeout
|
206
|
// set request timeout
|
|
|
|
|
247
|
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
|
249
|
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
|
248
|
__block UIApplication * app = [UIApplication sharedApplication];
|
250
|
__block UIApplication * app = [UIApplication sharedApplication];
|
249
|
|
251
|
|
250
|
- // #115 handling task expired when application entering backgound for a long time
|
|
|
251
|
- UIBackgroundTaskIdentifier tid = [app beginBackgroundTaskWithName:taskId expirationHandler:^{
|
|
|
252
|
- NSLog([NSString stringWithFormat:@"session %@ expired", taskId ]);
|
|
|
253
|
- [expirationTable setObject:task forKey:taskId];
|
|
|
254
|
- // comment out this one as it might cause app crash #271
|
|
|
255
|
-// [app endBackgroundTask:tid];
|
|
|
256
|
- }];
|
|
|
257
|
-
|
|
|
258
|
}
|
252
|
}
|
259
|
|
253
|
|
260
|
// #115 Invoke fetch.expire event on those expired requests so that the expired event can be handled
|
254
|
// #115 Invoke fetch.expire event on those expired requests so that the expired event can be handled
|