iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
来源:互联网 发布:linux vim 配置 c 编辑:程序博客网 时间:2024/05/18 04:01
错误日志:
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f999be478d0> { URL: myUrlXXXXXX } { status code: 200, headers {
"Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=utf-8";
Date = "Tue, 24 Nov 2015 09:06:04 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
Pragma = "no-cache";
Server = "nginx/1.1.19";
"Set-Cookie" = "PHPSESSID=qdvtek1k91oeva2u8fats39l93; path=/";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.3.10-1ubuntu3.21";
} }, NSErrorFailingURLKey=http:URL: myUrlXXXXXX, com.alamofire.serialization.response.error.data=<7b226572 726f725f 636f6465 223a302c 22657272 6f725f6d 7367223a 22222c22 75706c6f 61645f75 726c223a 22687474 703a5c2f 5c2f7777 772e7467 7370792e 636f6d5c 2f6c6f6f 70657273 5c2f7365 72766572 5c2f6269 6e5c2f63 7573746f 6d65725c 2f75706c 6f61645c 2f373332 31746f75 7869616e 672e6a70 67227d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
原因:
不可接受的内容类型 “text/html”
解决方案:
AFJSONResponseSerializer.m中,222行左右
把 这句: self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
修改为:
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
但是建议如果不是没办法了最好不要去改动第三方的底层框架,不然可能这个地方可以,其他地方却不行了
- iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
- iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
- iOS 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html
- AFNetWorking 错误Request failed: unacceptable content-type: text/html"
- 使用AFNetworking遇到异常 Request failed: unacceptable content-type: text/html
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
- 使用AFNetworking网络请求时出现错误"Request failed: unacceptable content-type: text/html"
- AFNetworking 报错 Request failed: unacceptable content-type: text/html
- AFNetworking 报错Request failed: unacceptable content-type: text/html"
- AFNetWorking请求时, “Request failed: unacceptable content-type: text/html”
- AFNetworking 错误 Request failed: unacceptable content-type: text/plain
- Request failed: unacceptable content-type: text/html" AFNetworking - 芒果iOS开发
- iOS"Request failed: unacceptable content-type: text/html"
- iOS"Request failed: unacceptable content-type: text/html"
- iOS"Request failed: unacceptable content-type: text/html"
- iOS开发 AFNetWork "Request failed: unacceptable content-type: text/html"
- iOS"Request failed: unacceptable content-type: text/html"
- Json对象与Json字符串互转(4种转换方式)
- 随笔
- 推荐几本学习MySQL的好书
- 通过配置文件ini配置数据库,操作数据库,以mysql为示例
- C++ Primer学习笔记(1)
- iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
- ArcMap中如何给shp文件的路线数据添加不同标注,添加不同颜色
- 百练_2765:八进制小数
- UE4 connect to 127.0.0.1 port 52314 failed: Connection refused)
- 深度学习基础知识(3):实现一个卷积神经网络
- 开始
- Nancy基于JwtBearer认证的使用与实现
- Codeforces 526C Om Nom and Candies 完全背包
- Java反射(五):java反射调用方法