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
最新文章
- [ASP.NET Core] Static File Middleware
- Liferay7 BPM门户开发之26: 集成Activiti到Liferay7
- 【云计算】开源的Docker Registry WebUI
- [Hibernate] - Study 1
- JS遇到的问题解决
- hdu 1018
- 分布式缓存BeIT Memcached简介
- HDU 1541 Stars (树状数组)
- C# 语言规范_版本5.0 (第1章 介绍)
- storybody中页面跳转
- Ninject之旅之十三:Ninject在ASP.NET MVC程序上的应用(附程序下载)
- VS2015 使用Xunit来进行单元测试
- AXI_DMA IP学习
- Linux超级守护进程&mdash;&mdash;xinetd
- [dart学习]第二篇:dart变量介绍 (一)
- 根据23423条件,截取字段‘abdecsdsadsadsad’,以ab/dec/sdsa/ds/ads 输出
- 遗忘Windows Server 2008R2密码的处理方法
- ref:linux用户和组管理,/etc/passwd,/etc/shadow和/etc/group 文件内容解释
- 转:Math: Math.atan() 与 Math.atan2() 计算两点间连线的夹角
- 记一次Castle报错