Finished by https 206 code
NSString *oldRange = urlSchemeTask.request.allHTTPHeaderFields[@"Range"];
oldRange = [oldRange substringFromIndex:6];
NSArray *array = [oldRange componentsSeparatedByString:@"-"];
NSInteger first = [[array firstObject] intValue];
NSInteger last = [[array lastObject] intValue];
NSLog(@"====> startURLSchemeTask2 response oldRange %@", oldRange);
NSRange newVideoRange = NSMakeRange(first, last - first + 1);
NSData *newVideoData = [videoData subdataWithRange:newVideoRange];
// 构造响应
NSError *error = nil;
NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:requestURL
statusCode:206
HTTPVersion:nil
headerFields:@{
@"Content-Range": [NSString stringWithFormat:@"bytes %lu-%lu/%lu", (unsigned long)first, (unsigned long)last, (unsigned long)videoData.length],
@"Content-Type": @"video/mp4",
@"Content-Length": [NSString stringWithFormat:@"%@", @(last - first + 1)],
@"Access-Control-Allow-Origin": @"*"
}];
Topic:
App & System Services
SubTopic:
Core OS
Tags: