NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解決方案,nslocalizedstring

來源:互聯網
上載者:User

NSLocalizedDescription=Request failed: unacceptable content-type: text/html 解決方案,nslocalizedstring

使用AFNetworking請求一個網站出現了以下錯誤

 

Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fc688f34d00> { URL: http://xxx.xxx.xxx } { status code: 200, headers {    "Content-Encoding" = gzip;    "Content-Type" = "text/html";    Date = "Sat, 10 Oct 2015 13:44:28 GMT";    Server = "nginx/1.4.1";    Vary = "Accept-Encoding";    "X-Cache" = "MISS from RJ-ZSBGP-CDN-75";    "X-Powered-By" = "PHP/5.4.16";} }, NSErrorFailingURLKey=http://xxx.xxx.xxx, com.alamofire.serialization.response.error.data=<7b227374 61746522 3a227375 63636573 73222c22 6d657373 61676522 3a22222c 22726573 756c7422 3a5b5d7d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}

 

解決方案:

修改AFNetworking中AFURLResponseSerialization.m檔案

在223行,將

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

改成

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

增加了一個 @"text/html"

 

如果你不是在wb145230部落格園看到本文,請點擊查看原文.

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.