AFNetworking content type not support
ref:http://blog.csdn.net/nyh1006/article/details/25068255
1、错误信息:Error:Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x16dcec00 {NSErrorFailingURLKey=http://www.weather.com.cn/data/sk/101110101.html, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x16d5deb0> { URL: http://www.weather.com.cn/data/sk/101110101.html } { status code: 200, headers {
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=utf-8";
Date = "Mon, 05 May 2014 09:40:27 GMT";
Server = "Apache/2.2.0";
"Transfer-Encoding" = Identity;
} }, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
原因:
AFNetworking 默认不支持text/html
AFURLResponseSerialization.m 源码 -> self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
解决办法:
1)在作者源代码处添加 @"text/html" 。
2)在自己的代码处加上这句代码:
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
缺什么类型就填那种类型,比如我是 text/plain
参考的资料:
http://www.cocoachina.com/bbs/simple/?t176000.html
http://www.cocoachina.com/ask/questions/show/108598
https://github.com/AFNetworking/AFNetworking/blob/master/README.md
AFNetworking content type not support的更多相关文章
- Java之POI读取Excel的Package should contain a content type part [M1.13]] with root cause异常问题解决
Java之POI读取Excel的Package should contain a content type part [M1.13]] with root cause异常问题解决 引言: 在Java中 ...
- org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
最后找到我的问题,springmvc配置文件中没加 <mvc:annotation-driven/> java代码: @RequestMapping(value="/reques ...
- Content type 'application/json;charset=UTF-8' not supported异常的解决过程
首先说一下当时的场景,其实就是一个很简单的添加操作,后台传递的值是json格式的,如下图 ,后台对应的实体类, @Data @EqualsAndHashCode(callSuper = false) ...
- Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...
- Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...
- SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...
- SharePoint自动化系列——Content Type相关timer jobs一键执行
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...
- 转载 SharePoint【Site Definition 系列】– 创建Content Type
转载原地址: http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...
- 安卓开发错误:The type android.support.v4.app.TaskStackBuilder$SupportParentable cannot be resolved.
今天在使用低版本下的ActionBar,在继承ActionBarActivity时报了"The type Android.support.v4.app.TaskStackBuilder$Su ...
随机推荐
- Lucene 简单手记http://www.cnblogs.com/hoojo/archive/2012/09/05/2671678.html
什么是全文检索与全文检索系统? 全文检索是指计算机索引程序通过扫描文章中的每一个词,对每一个词建立一个索引,指明该词在文章中出现的次数和位置,当用户查询时,检索程序就根据事先建立的索引进行查找,并将查 ...
- Android开发 R cannot be resolved to a variable问题的分析
R文件是系统自动生成的,如果没出现的话,你的XML文件是不是有错误?是否之前修改过res文件夹下面.xml文件 R文件没有生成的情况有几种: 1.项目没有自动编译:这种时候只需要简单的编译一下工程就会 ...
- Compress a folder using powershell
There are many ways to compress a folder using powershell: Method 1: Using System.IO.Compression and ...
- MySQL常用命令总结2
USE db_name; //使用(打开)数据库 SELECT DATABASE(); //查看当前打开的数据库 CREATE TABLE tb_name( column_name data_type ...
- Fragment里面嵌套Fragment的问题
最近两天做项目时,要在fragment里面嵌套Fragment,最开始使用Fragment的hide,show等方法一直失败,,如图,message是一个fragment,在里面又有两个子fragme ...
- iptables详解--转
出处:http://yijiu.blog.51cto.com/433846/1356254 iptables详解 基本概念: 1.防火墙工作在主机边缘:对于进出本网络或者本主机的数据报文,根据事先设定 ...
- gen_grant_exec.sql
set echo off feedback off verify off pagesize 0 linesize 120 define v_grantee = & ...
- jQuery常用及基础知识总结(一)
Attribute: $(”p”).addClass(css中定义的样式类型); 给某个元素添加样式$(”img”).attr({src:”test.jpg”,alt:”test Image”}); ...
- Struts1.x教程:配置文件总结
要想使用Struts,至少要依靠两个配置文件:web.xml和struts-config.xml.其中web.xml用来安装Struts框架.而struts-config.xml用来配置在Struts ...
- android-------手写签名系统的设计与实现之实现画笔设置
引自:http://www.xuebuyuan.com/1754358.html 既然我们实现了画布和画笔,也实现了手写,为了提高可用性,我们增加了对画笔风格的设置功能,这样就可以根据自己的需要选择画 ...