iOS"Request failed: unacceptable content-type: text/html"

每次更新ADNetworking都要改,唉
下面是錯誤信息:

獲取服務器響應出錯

error=ErrorDomain=com.alamofire.error.serialization.response
Code=-1016"Request failed: unacceptable content-type:text/html"
UserInfo=0x7fdfd8729680{com.alamofire.serialization.response.error.response= { URL:http://172.16.1.31:7001/itom/getwork } { status code: 200, 
headers{
"Cache-Control" = "no-cache";

"Content-Type" = "text/html;charset=UTF-8";

Date= "Mon, 24 Nov 2014 03:13:16 GMT";

"Transfer-Encoding" = Identity;

"X-Powered-By" = "Servlet/2.5 JSP/2.1";

} },NSErrorFailingURLKey=http://172.16.1.31:7001/itom/getwork,com.alamofire.serialization.response.error.data=<5b7b227374617475 73223a22 73756363 65737322 2c226d73 67223a22 e799bbe99986e688 90e58a9f 227d5d>,
NSLocalizedDescription=Requestfailed: unacceptable content-type: text/html}

對應到自己的項目里面,我用的是AFNetworking這套網絡請求包,需要改的是:

AFURLResponseSerialization.m文件

223行:

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

加上@"text/html"部分,其實就是添加一種服務器返回的數(shù)據(jù)格式。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容