星空网 > 软件开发 > 操作系统

AFNetWorking出现code=

报错类似:

2015-12-09 15:58:03.062 Carloans[14328:2300485] Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fe5ac728b50> { URL: http://api.lizicaifu.com/api.php?s=/Member/index.html&token=e0e9162086738e15a066daed1ff94baa&user_token=c8d353b0008099ba72fbcfea0b16f1c3 } { 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";
Date = "Wed, 09 Dec 2015 07:57:58 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
Pragma = "no-cache";
Server = nginx;
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.5.29";
} }, NSErrorFailingURLKey=http://api.lizicaifu.com/api.php?s=/Member/index.html&token=e0e9162086738e15a066daed1ff94baa&user_token=c8d353b0008099ba72fbcfea0b16f1c3, com.alamofire.serialization.response.error.data=<7b227374 61747573 223a2d33 2c22696e 666f223a 225c7538 6266375c 75393163 645c7536 3562305c 75373637 625c7535 66353522 2c226669 72737422 3a6e756c 6c2c226c 61737422 3a224144 38444444 45322d41 4642312d 34343130 2d423536 452d3634 46434331 32303241 4134227d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}

1.修改内部文件

AFURLResponseSerialization.m 这个文件找到这句话self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; 然后把 text/html 加进去就可以了! 试试,我就是这么干的。

2.在外面修改

2.0已经对各种方法做了优化,也不需要用AFJSONRequestOperation,2.0已经自带JSON解析。 
你可以用AFHTTPRequestOperationManager解决一切问题,遇到你的这个问题,你可以像这么写: 
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//设置相应内容类型 
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { 
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
}]; 
2.0会对返回的JSON或者


原标题:AFNetWorking出现code=

关键词:net

net
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

头程宝:https://www.goluckyvip.com/news/8009.html
注意!近期这类产品进出口,海关或将要求提供RoHS认证标识!:https://www.goluckyvip.com/news/801.html
飞高物流:https://www.goluckyvip.com/news/8010.html
旗丰海外仓:https://www.goluckyvip.com/news/8011.html
合新物流:https://www.goluckyvip.com/news/8012.html
大森林物流:https://www.goluckyvip.com/news/8013.html
新喀里多尼亚/new caledonia:https://www.kjdsnews.com/a/1836448.html
美国对13家与俄罗斯相关的加密货币金融科技公司实施制裁:https://www.kjdsnews.com/a/1836449.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流