标签:
Solution:Overriding request headers in SDWebImage
Looking for the file "SDWebImageDownloader.m"
replace
#ifdef SD_WEBP _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; #else _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8"} mutableCopy]; #endif
to
#ifdef SD_WEBP _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; #else _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8;q=0.9,*/*"} mutableCopy]; #endif
SDWebImageDownloader is a Singleton object in iOS
so we could set a custom header value to ‘Accept‘ header to override the default header.
[SDWebImageDownloader.sharedDownloader setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" forHTTPHeaderField:@"Accept"]; [self.imageView sd_setImageWithURL:[self imageUrlForId:imageId] placeholderImage:image];
SDWebImage : NSURLErrorDomain - Code = 406
标签:
原文地址:http://www.cnblogs.com/nielsen/p/5286616.html