ChangbaDevs / KTVHTTPCache

A powerful media cache framework.
MIT License
2.37k stars 436 forks source link

是否提供两个同时缓存? #71

Closed poholo closed 6 years ago

poholo commented 6 years ago

抖音缓存模式是在播放当前的视频时,缓存下一个,没具体看缓存了多少。我也有类似的需求,在我cache一个的时候,我通过NSURLSession下载一点,task cancel掉之后,HTTPCache却全部下载完了,有没有对应的api或者什么设置的请求size的设置~

poholo commented 6 years ago

找到方法,设置请求的Range即可

18211082419 commented 6 years ago

你好,你说的设置请求的Range怎么设置呢?谢谢

poholo commented 6 years ago

` NSString url = @"url"; NSString proxyUrl = [KTVHTTPCache proxyURLStringWithOriginalURLString:url];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:proxyUrl]
                                                       cachePolicy:NSURLRequestReloadIgnoringCacheData
                                                   timeoutInterval:10];

NSString *range = [NSString stringWithFormat:@"bytes=0-%zd", self.maxLength];
[request setValue:range forHTTPHeaderField:@"Range"];

self.task = [self.session downloadTaskWithRequest:request];`
18211082419 commented 6 years ago

多谢,多谢

guanbo123456 commented 6 years ago

这个range默认值是多少

poholo commented 6 years ago

默认是你资源的最大值~