首页 > 移动平台 > 详细

iOS"Request failed: unacceptable content-type: text/html"

时间:2015-08-31 13:09:41      阅读:261      评论:0      收藏:0      [点我收藏+]

I also encountered the same problem. This means that your server is sending "text/html" instead of the already supported types. After a little search, my solution was to add "text/html" to acceptableContentTypes set in AFURLResponseSerialization class. Just search for "acceptableContentTypes" and add @"text/html" to the set manually. Of course, the ideal solution will be to change the tpe from the server, but for that you will hade to talk with the server team.

I hope this helps you. Best regards and less bugs as possible in the code.

 op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html”];

 

修改AFNetworking网络请求框架:

AFURLResponseSerialization.m文件

223行:

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

加上蓝色部分,其实就是添加一种服务器返回的数据格式。

iOS"Request failed: unacceptable content-type: text/html"

原文:http://www.cnblogs.com/now-or-never/p/4772824.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!