From 26698f9da0e09216b305f3d990e02f60dc9c4727 Mon Sep 17 00:00:00 2001 From: Marco Meschini Date: Fri, 12 Jun 2015 16:58:04 +0100 Subject: [PATCH] add webp accepted content type only if WebP enabled Send WebP as accepted content type only if it is enabled. In case it's not, stick with the standard formats in order to avoid the server sending us back WebP images. --- SDWebImage/SDWebImageDownloader.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index a649a2405..40de86de8 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -67,7 +67,11 @@ - (id)init { _downloadQueue = [NSOperationQueue new]; _downloadQueue.maxConcurrentOperationCount = 6; _URLCallbacks = [NSMutableDictionary new]; - _HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"]; +#ifdef SD_WEBP + _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; +#elseif + _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8"} mutableCopy]; +#endif _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); _downloadTimeout = 15.0; }