|
|
|
@@ -352,15 +352,20 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
|
|
|
|
{
|
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
|
Class class = [NSURLSessionTask class];
|
|
|
|
|
// In iOS 7 resume lives in __NSCFLocalSessionTask
|
|
|
|
|
// In iOS 8 resume lives in NSURLSessionTask
|
|
|
|
|
// In iOS 9 resume lives in __NSCFURLSessionTask
|
|
|
|
|
Class class = Nil;
|
|
|
|
|
if (![[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
|
|
|
|
|
class = NSClassFromString([@[@"__", @"NSC", @"FLocalS", @"ession", @"Task"] componentsJoinedByString:@""]);
|
|
|
|
|
} else if ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion < 9) {
|
|
|
|
|
class = [NSURLSessionTask class];
|
|
|
|
|
} else {
|
|
|
|
|
class = NSClassFromString([@[@"__", @"NSC", @"FURLS", @"ession", @"Task"] componentsJoinedByString:@""]);
|
|
|
|
|
}
|
|
|
|
|
SEL selector = @selector(resume);
|
|
|
|
|
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
|
|
|
|
|
|
|
|
|
if ([self instanceRespondsButDoesNotImplementSelector:selector class:class]) {
|
|
|
|
|
// Dummy NSURLSessionTask to get the actual class, needed for iOS 7 (__NSCFURLSessionTask)
|
|
|
|
|
class = [[[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@"about:blank"]] superclass];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Method originalResume = class_getInstanceMethod(class, selector);
|
|
|
|
|
|
|
|
|
|
void (^swizzleBlock)(NSURLSessionTask *) = ^(NSURLSessionTask *slf) {
|
|
|
|
@@ -1151,7 +1156,8 @@ static char const * const kFLEXRequestIDKey = "kFLEXRequestIDKey";
|
|
|
|
|
FLEXInternalRequestState *requestState = [self requestStateForRequestID:requestID];
|
|
|
|
|
|
|
|
|
|
if (!requestState.dataAccumulator) {
|
|
|
|
|
requestState.dataAccumulator = [[NSMutableData alloc] initWithCapacity:(NSUInteger)totalBytesExpectedToWrite];
|
|
|
|
|
NSUInteger unsignedBytesExpectedToWrite = totalBytesExpectedToWrite > 0 ? (NSUInteger)totalBytesExpectedToWrite : 0;
|
|
|
|
|
requestState.dataAccumulator = [[NSMutableData alloc] initWithCapacity:unsignedBytesExpectedToWrite];
|
|
|
|
|
[[FLEXNetworkRecorder defaultRecorder] recordResponseReceivedWithRequestID:requestID response:downloadTask.response];
|
|
|
|
|
|
|
|
|
|
NSString *requestMechanism = [NSString stringWithFormat:@"NSURLSessionDownloadTask (delegate: %@)", [delegate class]];
|
|
|
|
|