码迷,mamicode.com
首页 > Web开发 > 详细

修改AFNetworking源文件可接收text/plain和text/html的方法

时间:2015-04-27 11:24:28      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

 在使用AFNetworking的时候可能会碰到下面的错误:

    { status code: 200, headers {

    "Content-Length" = 14;

    "Content-Type" = "text/plain;charset=utf-8";

    Date = "Thu, 22 May 2014 10:37:50 GMT";

    Server = "Apache-Coyote/1.1";

    "Set-Cookie" ="JSESSIONID=C0DFED60A154557F8386E62AB2A066CE; Path=/FHJRDT";

    } }, NSLocalizedDescription=Request failed:unacceptable content-type: text/plain}


    此时需要修改AFNetworking可接收的Content-Type,前往AFNetworking源代码目录找到AFURLResponseSerialization.m文件将里面的代码:

    self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json",@"text/javascript",nil];

    修改为:

    self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html",nil];

    self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json", @"text/javascript" ,@"text/plain" , nil];



修改AFNetworking源文件可接收text/plain和text/html的方法

标签:

原文地址:http://blog.csdn.net/huanghaiyan_123/article/details/45306025

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!