使用AFNetworking请求一个网站出现了以下错误

Error Domain=com.alamofire.error.serialization.response Code=- "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fc688f34d00> { URL: http://xxx.xxx.xxx }
{ status code: , headers {
"Content-Encoding" = gzip;
"Content-Type" = "text/html";
Date = "Sat, 10 Oct 2015 13:44:28 GMT";
Server = "nginx/1.4.1";
Vary = "Accept-Encoding";
"X-Cache" = "MISS from RJ-ZSBGP-CDN-75";
"X-Powered-By" = "PHP/5.4.16";
} }, NSErrorFailingURLKey=http://xxx.xxx.xxx, com.alamofire.serialization.response.error.data=<7b227374 61746522 3a227375 63636573 73222c22 6d657373 61676522 3a22222c 22726573 756c7422 3a5b5d7d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}

解决方法:

修改AFNetworking中AFURLResponseSerialization.m文件

在223行,将

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

改成

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

增加了一个 @"text/html"

如果你不是在wb145230博客园看到本文,请点击查看原文.

NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解决方法的更多相关文章

  1. AFNetworking request failed unacceptable content type text/html

    今天体验AFNetwork 3.1.0 进行数据解析,但是解析数据控制台一直都输出这样的 error 结果: 于是,照着以前AFN2.+版本的进行设置: 结果发现在新版本的 AFN 上不能设置了.既然 ...

  2. AFNetworking 2.0 获取json数据时,返回 NSLocalizedDescription=Request failed: unacceptable content-type: text/html, 解决方法.

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSe ...

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

    接口访问出错了,用浏览器测试,发现可以正常返回数据. 下面是错误信息: 获取服务器响应出错 error=Error Domain=com.alamofire.error.serialization.r ...

  4. iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html

    错误日志: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacc ...

  5. iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html

    错误日志是: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unac ...

  6. Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html"

    2015-11-16 10:39:17.235 PullDemo[338:60b] Application windows are expected to have a root view contr ...

  7. 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法

    使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...

  8. iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题

    使用AFNetworking出现报错: error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "R ...

  9. AFNetworking 遇到错误 Code=-1016 "Request failed: unacceptable content-type: text/plain"

    在开发过程使用了AFNetworking库,版本2.x,先运行第一个官方例子(替换GET 后面的url即可): AFHTTPRequestOperationManager *manager = [AF ...

随机推荐

  1. POJ - 2236Wireless Network-并查集

    id=11125" target="_blank" style="color:blue; text-decoration:none">POJ - ...

  2. python 设计模式之 单例模式

    单例模式是做为"全局变量"的替代品出现的.所以它具有全局变量的特点:全局可见.贯穿应用程序的整个生命期,保证在程序执行中,某个类仅仅存在一个实例,所以通常不希望类中的构造函数被调用 ...

  3. QT类库与Delphi VCL类库的体系结构对比——两者十分类似!

    今天在看QT对象内存管理的一篇文章时:http://blog.csdn.net/dbzhang800/article/details/6300025想到了一个问题:就是QT类库体系结构与Delphi类 ...

  4. Linux初接触随笔02

    刚开始把Linux既拿来用,又拿来学习怎么用,感觉真不顺手,手上应该有一本实体书籍,专门拿来学习用会好点,但是我现在手头没有,又把系统作为日常使用,只能说太不友好了,坚持不住了,以后等需要用的时候再弄 ...

  5. storm 经常使用类

    弄 <dependency> <groupId>org.apache.storm</groupId> <artifactId>storm-core< ...

  6. JSP和Servlet学习笔记1 - 访问配置

    1. 访问 WebContent 目录下的 JSP 文件 在 WebContent 目录下的文件可以直接在浏览器中访问.新建一个 test.jsp 文件 <%@ page language=&q ...

  7. Spring+SpringMVC+MyBatis+easyUI

    Spring+SpringMVC+MyBatis+easyUI 日常啰嗦 还好在第一篇文章里就列好了接下来的主线及要写的知识点,不然都不知道要写什么东西了,开篇里已经列了基础篇要讲svn和git的知识 ...

  8. sql获取数据库的所有表以及名称字段

    获取数据库中所有的表 SELECT SysObjects.name AS Tablename FROM sysobjects WHERE xtype = 'U' 获取数据库中所有表的列名 SELECT ...

  9. Dictionary(数据字典)

    数据字典:Dictionary对象用于在结对的名称/值中存储信息(等同于键和项目),其可作为传参使用. C# Dictionary字典类的使用方法 //定义字典 Dictionary<strin ...

  10. Airflow 使用简介