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

来源:互联网 发布:玲珑加速器mac怎么样 编辑:程序博客网 时间:2024/04/29 09:50

经常在使用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 ,增加相应的.

1 0
原创粉丝点击