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

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

 

复制代码
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"

转载于:https://www.cnblogs.com/bugismyalllife/p/4872100.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值