AFNetWorking无返回数据 Code=-1016
2016-01-26 15:01
169 查看
Printing description of error:
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse:
0x7f7fa1700070> { URL: http://192.168.10.155:80/WebService/ } { status code: 200, headers {
Connection = close;
"Content-Length" = 111;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Tue, 26 Jan 2016 06:53:25 GMT";
Server = "Apache/2.2.15 (CentOS)";
"X-Powered-By" = "PHP/5.3.3";
} }, NSErrorFailingURLKey=http://192.168.10.155:80/WebService/, com.alamofire.serialization.response.error.data=<7b22746f 6b656e22 3a226163 37333844 4d6d4c50 39505c2f
5a574650 425c2f77 665c2f32 3837636a 39487178 466b385c 2f723655 39364162 4e544f33 4b414c7a 5131416f 67483548 7a6a7556 45725768 6b306668 4d505248 2b506c71 354d4d77 222c2263 6f646522 3a223030 31227d>, NSLocalizedDescription=Request failed: unacceptable content-type:
text/html}
在使用AFNetWorking进行网络请求时,请求不到数据,error的信息显示如上所示。其原因是failed: unacceptable content-type: text/html。
AFNetWorking默认不支持text/html,
AFURLResponseSerialization.m
源码 -> self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
那么需要修改一下。
AFHTTPSessionManager *session = [AFHTTPSessionManager
manager];
[session.responseSerializer.acceptableContentTypes
= [NSSet setWithObject:@"text/html"];
over!
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse:
0x7f7fa1700070> { URL: http://192.168.10.155:80/WebService/ } { status code: 200, headers {
Connection = close;
"Content-Length" = 111;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Tue, 26 Jan 2016 06:53:25 GMT";
Server = "Apache/2.2.15 (CentOS)";
"X-Powered-By" = "PHP/5.3.3";
} }, NSErrorFailingURLKey=http://192.168.10.155:80/WebService/, com.alamofire.serialization.response.error.data=<7b22746f 6b656e22 3a226163 37333844 4d6d4c50 39505c2f
5a574650 425c2f77 665c2f32 3837636a 39487178 466b385c 2f723655 39364162 4e544f33 4b414c7a 5131416f 67483548 7a6a7556 45725768 6b306668 4d505248 2b506c71 354d4d77 222c2263 6f646522 3a223030 31227d>, NSLocalizedDescription=Request failed: unacceptable content-type:
text/html}
在使用AFNetWorking进行网络请求时,请求不到数据,error的信息显示如上所示。其原因是failed: unacceptable content-type: text/html。
AFNetWorking默认不支持text/html,
AFURLResponseSerialization.m
源码 -> self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
那么需要修改一下。
AFHTTPSessionManager *session = [AFHTTPSessionManager
manager];
[session.responseSerializer.acceptableContentTypes
= [NSSet setWithObject:@"text/html"];
over!
相关文章推荐
- afnetworking 和 asihttprequest 强制修改http连接的host地址
- AFNetworking+Nginx+HTTPS自签名服务器安全通信
- iOS应用网络安全之HTTPS
- 封装AFNetworking网络工具类(Objective-C)
- AFNetworking下载数据Demo
- swifty引用AFNetworking出现clang: error: linker command failed with exit code 1 (use -v to see invocation
- cocoapods 类库管理利器
- iOS学习之 AFNetworking的使用(一)
- AFNetworking的Post请求
- 【IOS开发】swift版的AFNETworking之Alamofire的用法 图片上传
- 使用Swift调用AFNetworking进行网络请求
- Swift中的HTTP请求
- AFNetworking 新版本3.0的迁移(最新为3.0.4)
- Swift 下AFNetworking得使用
- AFNetWorking的基本使用
- AFNetworking post请求
- AFNetworking判断当前手机的网络状态
- iOS开发网络数据之AFNetworking使用
- 对比iOS网络组件:AFNetworking VS ASIHTTPRequest
- AFNetworking