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 ...
随机推荐
- margin传递,子元素的上下margin会传递给父级
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- Vim插件管理 -- Vundle
1 插件目录 -/.vim/bundle/ 没有可自行创建 2 安装Vundle $ git clone https://github.com/VundleVim/Vundle.vim.git ...
- 使用NGUI进行类似Button的操作
下面例子以Label和Sprite为例,进行说明如何在NGUI中对控件添加单击响应的事件方法. 首先在UIRoot下添加Label控件,然后Scene场景中右键Label-->Attach--& ...
- startActivityForResult相关的
在Fragment里调用startActivityForResult,界面回来后,会先走其宿主Activity的onActivityResult方法,再走Fragment的. 在Fragment里面嵌 ...
- Codeforces Round #349 (Div. 2) C. Reberland Linguistics (DP)
C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Struts2 语法--异常处理
1. UsersDAO.java里产生一个例外: System.out.println(1/0); 2. 调用DAO的UsersAction1.java 的execute方法, 加抛异常: publi ...
- TCP/IP网络协议栈(转载)
原文:http://www.cnblogs.com/xuanku/p/tcpip.html TCP/IP网络协议栈分为四层, 从下至上依次是: 链路层 其实在链路层下面还有物理层, 指的是电信号的传输 ...
- javascript OOP 面向对象编程
Pseudo-class declaration 原文地址:http://javascript.info/tutorial/pseudo-classical-pattern#pseudo-class- ...
- Gerald and Giant Chess
Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Exponential notation
Exponential notation You are given a positive decimal number x. Your task is to convert it to the &q ...