iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html
错误日志是:
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fc8b970eb70> { URL: http://www.aifish.top/register.php?userid=123&password=123 } { status code: 200, headers {
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html";
Date = "Mon, 29 Aug 2016 03:13:37 GMT";
Server = Tengine;
"Transfer-Encoding" = Identity;
Vary = "Accept-Encoding, Accept-Encoding";
} }, NSErrorFailingURLKey=http://www.aifish.top/register.php?userid=123&password=123, com.alamofire.serialization.response.error.data=<7b226661 696c5f6d 7367223a 7b227374 72696e67 223a2264 61746120 65786973 74227d2c 22756964 5f666169 6c223a7b 22737472 696e6722 3a223132 33227d7d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
通常我用
NSMutableSet *set = [NSMutableSet setWithSet:manager.responseSerializer.acceptableContentTypes];
[set addObject:@"text/html"];
就可以解决了, 不知道这次怎么不行, 只要自己打印下就知道到底有没有加上了.
NSLog(@"%@", manager.responseSerializer.acceptableContentTypes);
然后在AF的AFJSONResponseSerializer.m中,228行左右
把 这句: self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
修改为:
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
打印一下contentTypes就知道加没加上了.❤️
iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html的更多相关文章
- AFNetworking request failed unacceptable content type text/html
今天体验AFNetwork 3.1.0 进行数据解析,但是解析数据控制台一直都输出这样的 error 结果: 于是,照着以前AFN2.+版本的进行设置: 结果发现在新版本的 AFN 上不能设置了.既然 ...
- iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
错误日志: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacc ...
- AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html 原因: 不可接受的内容类型 “text/html ...
- iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题
使用AFNetworking出现报错: error=Error Domain=com.alamofire.error.serialization.response Code=-1016 "R ...
- iOS"Request failed: unacceptable content-type: text/html"
接口访问出错了,用浏览器测试,发现可以正常返回数据. 下面是错误信息: 获取服务器响应出错 error=Error Domain=com.alamofire.error.serialization.r ...
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...
- AFNetworking 遇到错误 Code=-1016 "Request failed: unacceptable content-type: text/plain"
在开发过程使用了AFNetworking库,版本2.x,先运行第一个官方例子(替换GET 后面的url即可): AFHTTPRequestOperationManager *manager = [AF ...
- 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 ...
- NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解决方法
使用AFNetworking请求一个网站出现了以下错误 Error Domain=com.alamofire.error.serialization.response Code=- "Req ...
随机推荐
- Hadoop 数据库 - HBase
转自:http://blog.csdn.net/iAm333 1 什么是HBase? HBase,是Hadoop Database,是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统.使用HBas ...
- c++字符串互相转换
1.string vs char* //string to char* string str; const char* cch = str.c_str(); ]; strcpy(ch,cch); // ...
- python之2048
#-*- coding:utf-8 -*- import curses from random import randrange, choice # generate and place new ti ...
- docker containerd中的容器操作
containerd的中的各种操作都是通过Task来进行的,因此对于容器的create, start, delete等等操作其实都是一个个的Task而已. Task的数据结构如下所示: type Ta ...
- UESTC 1237 质因子分解
水题一枚.. #include<iostream> #include<cstdio> #include<cstring> #include<cmath> ...
- 在Unity中为模型使用表情
在游戏中让角色能够拥有表情,是我一直很想实现的一件事情,今天搜索了一下这方面的资料,找到两个解决方案. MMD For Unity GitHub:https://github.com/mmd-for- ...
- C# 程序性能提升篇-1、装箱和拆箱,枚举的ToString浅析
前景提要: 编写程序时,也许你不经意间,就不知不觉的使程序代码,发生了装箱和拆箱,从而降低了效率,不要说就发生那么一次两次,如果说是程序中发生了循环.网络程序(不断请求处理的)等这些时候,减少装箱和拆 ...
- java 16 -3 Vector的特有功能
/* * Vector的特有功能: * 1:添加功能 替代 * public void addElement(Object obj) -- add() * 2:获取功能 * public Object ...
- C#代码规范 .NET程序员需要提升的修养
一. 环境设置 首先去除VS开发环境中的一些选项如下: 粘贴时调整缩进 将类型的左大括号置于新行 将方法的左大括号置于新行 将匿名方法的左大括号置于新行 将控制块的左大括号置于新行 将“else” ...
- js对象深潜拷贝(从requirejs中抠出来的)
var op = Object.prototype, ostring = op.toString, hasOwn = op.hasOwnProperty; function isFunction(it ...