Merge pull request #591 from hsoi/downloader-timeout
Expose timeout property for the downloader.
This commit is contained in:
commit
48846851ee
|
@ -73,6 +73,13 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data,
|
|||
|
||||
@property (readonly, nonatomic) NSUInteger currentDownloadCount;
|
||||
|
||||
|
||||
/**
|
||||
* The timeout value (in seconds) for the download operation. Default: 15.0.
|
||||
*/
|
||||
@property (assign, nonatomic) NSTimeInterval downloadTimeout;
|
||||
|
||||
|
||||
/**
|
||||
* Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
|
||||
*/
|
||||
|
|
|
@ -72,6 +72,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
_URLCallbacks = NSMutableDictionary.new;
|
||||
_HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"];
|
||||
_barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT);
|
||||
_downloadTimeout = 15.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -121,8 +122,13 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
|
||||
[self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^
|
||||
{
|
||||
NSTimeInterval timeoutInterval = wself.downloadTimeout;
|
||||
if (timeoutInterval == 0.0) {
|
||||
timeoutInterval = 15.0;
|
||||
}
|
||||
|
||||
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest.alloc initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:15];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest.alloc initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval];
|
||||
request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies);
|
||||
request.HTTPShouldUsePipelining = YES;
|
||||
if (wself.headersFilter)
|
||||
|
|
Loading…
Reference in New Issue