Closed
Description
When using SDWebImage to download an jpg image from web, I got error below:
NSURLErrorDomain Code=403 "The operation couldn’t be completed
this is image url:
http://img5.imgtn.bdimg.com/it/u=3017210771,879699792&fm=11&gp=0.jpg
It shows ok in browser.
Activity
qingmu213 commentedon Jul 29, 2015
because is need User-Agent
in SDWebImageDownloader.m method init replace by
bpoplauschi commentedon Aug 5, 2015
Indeed, it seems this webserver requires a User-Agent before giving access to the image.
You don't need to modify the
SDWebImageDownloader
code.Before downloading the image, do:
[[SDWebImageDownloader sharedDownloader] setValue:userAgent forHTTPHeaderField:@"User-Agent"];
using an userAgent computed like in the example above.jiangyancong commentedon Jul 5, 2016
Excuse me, the solution works very well, but is there any plan to fix it in the branch? Thanks.
AndreaVitale commentedon Sep 19, 2016
Same problem with this sample url: https://static.pexels.com/photos/1475/food-vegetables-italian-restaurant-large.jpg.
Any helps?
jiangyancong commentedon Sep 20, 2016
@AndreaVitale Have you tried qingmu213's solution above?
AndreaVitale commentedon Sep 20, 2016
Yep, I tried setting the userAgent. It was loaded only for the first, second time. After that the server always return 403.