您的位置:首页 > 移动开发 > IOS开发

iOS- "unacceptable content-type: text/plain"等content-type bug解决方式

2017-07-09 16:12 681 查看

常常在使用AFN的时候会出现content-type错误,缺少请求类型,比方”unacceptable content-type: text/plain”

解决方法:
1.在网络请求代码处改动

AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
mgr.responseSerializer = [AFHTTPResponseSerializer serializer];

2.直接改动AFN源文件

1)找到AFN设定Content-type的地方
复制用-> AFURLResponseSerialization.m

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

改动为:

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

缺少什么类型的content-type ,添加对应的.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐