码迷,mamicode.com
首页 > Web开发 > 详细

SDWebImage : NSURLErrorDomain - Code = 406

时间:2016-03-17 12:47:34      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!