SDWebImage : NSURLErrorDomain - Code = 406
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];
如有疑问,共同探讨,共同进步。