Method to modify AFNetworking source file to receive text/plain and text/html_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:45:31
Original
873 people have browsed it

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];



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template