ios Request failed: unacceptable content-type: text/html"
Printing description of error:Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response={ URL: http://120.24.45.67/user/login } { status code: 200, headers {
"Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-cache";
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 117;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Thu, 29 Sep 2016 14:42:45 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
"Keep-Alive" = "timeout=5, max=100";
Pragma = "no-cache";
Server = "Apache/2.4.7 (Ubuntu)";
"Set-Cookie" = "PHPSESSID=mjbe8tpshmi5ru8e78v9ep8125; path=/, laravel_session=eyJpdiI6IkVkWjRuT2pybWFneEh2b2JNaTh6Zmc9PSIsInZhbHVlIjoiSlwvRHkxbUZmNG5BVnlEMjBVMm1pU1hHU2ljSk4zeHpZMDdMOGV1clRnRmRDVlNZc2dHTVRDQkNtVDFMeGtqMTc3dE5CNHRMcVlwZnVodGNHYUFPdmpnPT0iLCJtYWMiOiI3YTAyMmIyYThiNjZkZDM3Yzc4MjAxYTVlMzM0YjczZmJhOTFiMDQxYzAyZWMyM2NkZmQwYjMwZjkwMDA4ZDEzIn0%3D; expires=Thu, 29-Sep-2016 16:42:45 GMT; Max-Age=7200; path=/; httponly";
Vary = "Accept-Encoding";
"X-Powered-By" = "PHP/5.5.9-1ubuntu4.18";
} }, NSErrorFailingURLKey=http://120.24.45.67/user/login, com.alamofire.serialization.response.error.data=<7b22636f 6465223a 22353030 222c226d 7367223a 22e69caa e68ea5e6 94b6e588 b0e695b0 e68dae22 2c22696e 666f223a 7b227265 73756c74 223a2230 222c2275 6964223a 22222c22 6e69636b 6e616d65 223a2222 2c226176 61746172 223a2222 2c226163 63657373 746f6b65 6e223a22 227d7d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
仔細看下報錯資訊,大致意思就是在接收資料的時候缺少“text/html”這個內容型別。
解決辦法就是在AFNetWorking的responseSerializer裡面增加”text/html“這個內容型別。
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer new];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
這樣就大功告成了~但是一定要注意,responseSerializer使用之前一定要new一次,不然配置的東西無效。
也可以參考:
相關文章
- 06-記錄網路請求Request failed: unacceptable content-type: text/plain(AFNetworking)AI
- 使用AFNetworking 2.0 請求資料時出現錯誤 Request failed: unacceptable content-type: text/html 解決方法AIHTML
- request gap sequence is FailedAI
- Request和Response的HTTPHeader中的Content-TypeHTTPHeader
- text/html和text/plain的區別HTMLAI
- axios 修改Content-Type設定iOS
- jQuery html(),text(),val()區別jQueryHTML
- html:text的使用問題?HTML
- HTML input text單行文字域HTML
- jQuery的html()和text()區別jQueryHTML
- n [Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoAIExceptionRPC
- PostgreSQL Detail: Failed on request of size 8192 in memory context "ErrorContexSQLAIContextError
- JQuery中的html() text() val()區別jQueryHTML
- html:text初始值問題.急!!HTML
- android模擬器 一個錯誤:X Error of failed request: BadRequest (invalid request code or no such operation)...AndroidErrorAI
- Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight responHeader
- text(),val()和html()區別是什麼HTML
- [IOS]解決Failed to start Instruments daemon for ‘iOS’ on iPhoneiOSAIiPhone
- Axios 原始碼解讀 —— request 篇iOS原始碼
- struts 中多個html:text賦初值問題HTML
- ssh到圖形介面時報:X11 forwarding request failed on channel 0ForwardAI
- npm ERR! network request to https://registry.npmmirror.com/create-vite failed,NPMHTTPViteAI
- iOS TFHpple解析htmliOSHTML
- HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.BadSqlGramHTTPAIExceptionSpringFrameworkJDBCSQL
- npm報錯:request to https://registry.npm.taobao.org failed處理辦法NPMHTTPAI
- Content-Type一覽
- 在iOS中呼叫HTMLiOSHTML
- SAP CRM WebClient UI html 格式的 Text 顯示邏輯WebclientUIHTML
- v-html 、v-text({{}}) 、v-model的區別HTML
- Expected mime type application/octet-stream but got text/html.APPGoHTML
- 急急急急!Struts自定義標籤html:text 問題HTML
- npm報錯:request to https://registry.npm.taobao.org failed, reason certificate has expiredNPMHTTPAI
- 六九、ajax,fetch,axios,wx.request封裝iOS封裝
- Core Text Tutorial for iOS : Making a Magazine App 翻譯iOSAPP
- vue中的v-html,v-text,{{}}三種渲染模板VueHTML
- jQuery的text()、html()和val()函式用法簡單介紹jQueryHTML函式
- html:text property="ABoolean"輸出是"on"HTMLBoolean
- 理解HTTP之 content-typeHTTP