NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解决方法
2015-10-12 16:41
567 查看
使用AFNetworking请求一个网站出现了以下错误
解决方法:
修改AFNetworking中AFURLResponseSerialization.m文件
在223行,将
改成
增加了一个 @"text/html"
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fc688f34d00> { URL: http://xxx.xxx.xxx } { status code: 200, headers { "Content-Encoding" = gzip; "Content-Type" = "text/html"; Date = "Sat, 10 Oct 2015 13:44:28 GMT"; Server = "nginx/1.4.1"; Vary = "Accept-Encoding"; "X-Cache" = "MISS from RJ-ZSBGP-CDN-75"; "X-Powered-By" = "PHP/5.4.16"; } }, NSErrorFailingURLKey=http://xxx.xxx.xxx, com.alamofire.serialization.response.error.data=<7b227374 61746522 3a227375 63636573 73222c22 6d657373 61676522 3a22222c 22726573 756c7422 3a5b5d7d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
解决方法:
修改AFNetworking中AFURLResponseSerialization.m文件
在223行,将
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
改成
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
增加了一个 @"text/html"
相关文章推荐
- Android Studio在创建/导入项目的时候,一直处于building “XXX”gradle project info的解决办法
- POJ2299 Ultra-QuickSort 树状数组+离散化
- UI线程中调用Handler.post与直接执行方法的区别
- UITableView全面解析
- UITableView中常用方法
- Android 通过配置相同的UUid访问不同进程小结
- iOS UITableView
- ZooKeeper Programmer's Guide(ZooKeeper 3.4 Documentation)个人翻译
- CodeForces - 527D Clique Problem (图,贪心)
- Using Ambari Blueprint to Provision HDP automatically
- Android中UID机制和共享进程
- UITableView 多选删除功能 IOS
- UIPickerView
- The following classes could not be found - EditText (Change to android.widget.EditText, Fix Build Pa
- UINavigationController和页面间传值
- Java设计模式 —— 建造模式 (Builder)
- NSIS 的 Modern UI 教程(二)
- UI:使View背景逐渐变暗的方法
- BlueDroid 蓝牙启动流程分析
- Hdu 5496 Beauty of Sequence (组合数)