美文网首页
Kingfisher加载不出带逗号的图片url

Kingfisher加载不出带逗号的图片url

作者: 飛呈Geek | 来源:发表于2016-11-03 15:26 被阅读563次

ps:不是逗号的原因,但是逗号是这个url的特征,方便搜索
使用版本:3.1.3
如:http://img2.imgtn.bdimg.com/it/u=2627069709,2509213581&fm=21&gp=0.jpg

解决

参考
https://github.com/rs/SDWebImage/issues/1228

ImageDownloader.swift文件299行加入User-Agent

    func downloadImage(with url: URL,
              retrieveImageTask: RetrieveImageTask?,
                        options: KingfisherOptionsInfo?,
                  progressBlock: ImageDownloaderProgressBlock?,
              completionHandler: ImageDownloaderCompletionHandler?) -> RetrieveImageDownloadTask?
    {
        if let retrieveImageTask = retrieveImageTask, retrieveImageTask.cancelledBeforeDownloadStarting {
            return nil
        }
        
        let timeout = self.downloadTimeout == 0.0 ? 15.0 : self.downloadTimeout
        
        // We need to set the URL as the load key. So before setup progress, we need to ask the `requestModifier` for a final URL.
        var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: timeout)
        request.httpShouldUsePipelining = requestsUsePipeling
      //这儿
        request.allHTTPHeaderFields = ["User-Agent":"App/iOS"]
....下面省略

相关文章

网友评论

      本文标题:Kingfisher加载不出带逗号的图片url

      本文链接:https://www.haomeiwen.com/subject/kjzbuttx.html