iOS上传失败提示"Request failed: unacceptable content-type: text/html"
2016-03-12 11:39
465 查看
error=Error Domain=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=<5b7b2273 74617475 73223a22 73756363 65737322 2c226d7367223a22 e799bbe9 9986e688 90e58a9f 227d5d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}下面是百度出来的答案:I also encountered the same problem. This means that your server is sending
"text/html"instead of the already supported types. After a littlesearch, my solution was to add
"text/html"to
acceptableContentTypesset in
AFURLResponseSerializationclass. Just search for "acceptableContentTypes" and add
@"text/html"tothe set manually. Of course, the ideal solution will be to change the tpe from the server, but for that you will hade to talk with the server team.I hope this helps you. Best regards and less bugs as possible in the code.
op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html”];
对应到自己的项目里面,我用的是AFNetworking这套网络请求包,需要改的是:
AFURLResponseSerialization.m文件
223行:self.acceptableContentTypes = [NSSetsetWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript", nil];加上蓝色部分,其实就是添加一种服务器返回的数据格式。
相关文章推荐
- String,StringBuffer与StringBuilder之间的区别
- UIscrollView和UIPageControl的循环滚动
- MYSQL的索引类型:PRIMARY, INDEX,UNIQUE,FULLTEXT,SPAIAL 有什么区别?各适用于什么场合?
- Easyui datebox 限制时间选择范围
- 通过xib加载UITableViewCell的新方式
- 切换Fragment时避免重复加载UI
- NameValuePair在API22过时问题
- 使用 JDBC 连接 Hive(ClassNotFoundException、No suitable driver found、Could not open client transport wit)
- [LeetCode]232. Implement Queue using Stackssil
- Farey Sequence
- Builder模式
- iOS应用开发中UITabBarController标签栏控制器使用进阶
- Mycat 月分片方法 - pursuer.chen - 博客园
- [leetcode] 288. Unique Word Abbreviation 解题报告
- ${pageContext.request.contextPath} JSP取得绝对路径
- Question_one_数据库插入数据无法显示中文
- 1099. Build A Binary Search Tree (30)
- iOS学习 UITableViewCell 三种定制方法
- 【POJ 3368】Frequent values
- Request&&Response学习总结