标签:
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
标签:
原文地址:http://www.cnblogs.com/lucky-star-star/p/5866307.html