NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解决方法_html/css_WEB-ITnose

使用afnetworking请求一个网站出现了以下错误

 

  1. 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行,将

  1. self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];

登录后复制

改成

  1. self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];

登录后复制

增加了一个 @”text/html”

 

如果你不是在wb145230博客园看到本文,请点击查看原文.

 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

点点赞赏,手留余香

给TA打赏
共0人
还没有人赞赏,快来当第一个赞赏的人吧!
    编程技术

    [译]CSS-理解百分比的background-position_html/css_WEB-ITnose

    2025-3-29 9:21:37

    编程技术

    「CSS3 」3D效果 & 透视_html/css_WEB-ITnose

    2025-3-29 9:21:45

    0 条回复 A文章作者 M管理员
    欢迎您,新朋友,感谢参与互动!
      暂无讨论,说说你的看法吧
    个人中心
    购物车
    优惠劵
    今日签到
    私信列表
    搜索