Home > Article > Web Front-end > Method to modify AFNetworking source file to receive text/plain and text/html_html/css_WEB-ITnose
You may encounter the following error when using 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:un acceptable content- type: text/plain}
At this time you need to modify what AFNetworking can accept Content-Type, go to the AFNetworking source code directory to find the AFURLResponseSerialization.m file and change the code inside:
self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json",@"text/ javascript",nil];
Modified to:
self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json",@"text/javascript",@ "text/html",nil];
self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json", @"text/javascript" ,@"text/plain" , nil];