使用afnetworking请求一个网站出现了以下错误
- Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response= { 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=, 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”
如果你不是在wb145230博客园看到本文,请点击查看原文.
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。