We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.先pod 'HappyDNS', '~> 0.1.1'到项目中;
2.项目中使用QNDnsManager 返回ips; NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[QNResolver systemResolver]]; [array addObject:[[QNResolver alloc] initWithAddres:@"114.114.115.115"]]; QNDnsManager *dnsManager = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]]; NSArray *ips = [dnsManager query:@"http://xxxx.com2.z0.glb.qiniucdn.com"];
3.请求七牛图片时使用ip替换域名http://xxxx.com2.z0.glb.qiniucdn.com,并设置HTTPHeadField; [SDWebImageManager.sharedManager.imageDownloader setValue:@"http://xxxx.com2.z0.glb.qiniucdn.com" forHTTPHeaderField:@"Host"]; 注:自己封装请求图片时使用[request setValue: @"http://xxxx.com2.z0.glb.qiniucdn.com" forHTTPHeaderField:@"Host"];
4.项目中因为图片还有其他来源,这里区分使用设置HTTPHeadField中Host; SDWebImageManager.sharedManager.imageDownloader.headersFilter = ^NSDictionary *(NSURL *url, NSDictionary *headers) { NSMutableDictionary *mutableHeaders = [headers mutableCopy]; [mutableHeaders removeObjectForKey:@"Host"]; //是否为ip格式 if ([url.host rh_isIp]) { [mutableHeaders setValue:@"xxxx.com2.z0.glb.qiniucdn.com" forKey:@"Host"]; } return mutableHeaders; };
最后,谢谢longbai在此过程中提供的帮助,由于缺少相关文档,冒昧抛砖引玉,希望可以帮助到小伙伴们,欢迎一起交流!
The text was updated successfully, but these errors were encountered:
@iTA9178 十分感谢啊,这个地方 还有可以优化的地方 就是使用NSURLProtocol 这样代码会更干净些,另外可以对这些IP 进行挨个重试,假如一个失败 就切换到下一个
Sorry, something went wrong.
@neil-wu 需要设置 Host header
... use domain to set
No branches or pull requests
1.先pod 'HappyDNS', '~> 0.1.1'到项目中;
2.项目中使用QNDnsManager 返回ips;
NSMutableArray *array = [[NSMutableArray alloc]init];
[array addObject:[QNResolver systemResolver]];
[array addObject:[[QNResolver alloc] initWithAddres:@"114.114.115.115"]];
QNDnsManager *dnsManager = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
NSArray *ips = [dnsManager query:@"http://xxxx.com2.z0.glb.qiniucdn.com"];
3.请求七牛图片时使用ip替换域名http://xxxx.com2.z0.glb.qiniucdn.com,并设置HTTPHeadField;
[SDWebImageManager.sharedManager.imageDownloader setValue:@"http://xxxx.com2.z0.glb.qiniucdn.com" forHTTPHeaderField:@"Host"];
注:自己封装请求图片时使用[request setValue: @"http://xxxx.com2.z0.glb.qiniucdn.com" forHTTPHeaderField:@"Host"];
4.项目中因为图片还有其他来源,这里区分使用设置HTTPHeadField中Host;
SDWebImageManager.sharedManager.imageDownloader.headersFilter = ^NSDictionary *(NSURL *url, NSDictionary *headers)
{
NSMutableDictionary *mutableHeaders = [headers mutableCopy];
[mutableHeaders removeObjectForKey:@"Host"];
//是否为ip格式
if ([url.host rh_isIp])
{
[mutableHeaders setValue:@"xxxx.com2.z0.glb.qiniucdn.com" forKey:@"Host"];
}
return mutableHeaders;
};
最后,谢谢longbai在此过程中提供的帮助,由于缺少相关文档,冒昧抛砖引玉,希望可以帮助到小伙伴们,欢迎一起交流!
The text was updated successfully, but these errors were encountered: