AFNetWorking无返回数据 Code=-1016

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!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值