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

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

解决方法:

1.在网络请求代码处改动

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

2.直接改动AFN源文件

1)找到AFN设定Content-type的地方

复制用-> AFURLResponseSerialization.m

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

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 ,添加对应的.