zoukankan      html  css  js  c++  java
  • NSLocalizedDescription=Request failed: unacceptable content-type: text/html

    今天在做上传图片的时候,突然总是报错,用client或者postman是正常的,看了下报错信息

    2015-09-16 14:19:37.665 kuaixiu-vendor[12897:2996954] error:Error Domain=com.alamofire.error.serialization.response Code=-1016 “Request failed: unacceptable content-type: text/html” UserInfo=0x1702e1700 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x174235540> { URL: http://192.168.1.31/kuaixiu/web/app_dev.php/apishop/upload } { status code: 200, headers {

        “Cache-Control” = “no-cache”;

        Connection = “Keep-Alive”;

        “Content-Encoding” = gzip;

        “Content-Type” = “text/html; charset=UTF-8”;

        Date = “Wed, 16 Sep 2015 06:19:33 GMT”;

        “Keep-Alive” = “timeout=5, max=100”;

        Server = “Apache/2.4.7 (Ubuntu)”;

        “Transfer-Encoding” = Identity;

        Vary = “Accept-Encoding”;

        “X-Debug-Token” = 3b15f2;

        “X-Powered-By” = “PHP/5.5.9-1ubuntu4.11”;

    } }, NSErrorFailingURLKey=http://192.168.1.31/kuaixiu/web/app_dev.php/apishop/upload, com.alamofire.serialization.response.error.data=<7b22636f 6465223a 312c226d 65737361 6765223a 225c7534 6530615c 75346632 305c7536 3231305c 75353239 665c7566 66303122 2c226461 7461223a 22353566 39303966 35633636 35632e6a 7067227d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}

    仔细看下报错信息,大致意思就是在接收数据的时候缺少“text/html”这个内容类型。

    解决办法就是在AFNetWorking的responseSerializer里面增加”text/html“这个内容类型。

    1
    2
    3
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFJSONResponseSerializer new];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html"nil];

    这样就大功告成了~但是一定要注意,responseSerializer使用之前一定要new一次,不然配置的东西无效。

     

  • 相关阅读:
    一千行 MySQL 学习笔记
    linux学习(二)
    linux学习(二)
    内联元素
    内联因素1.默认内容撑开盒子大小
    定位absolute使内联支持宽高(块属性变为内联,内容默认撑开)margin auto 失效
    over
    float浮动问题:会造成父级元素高度坍塌;
    float的元素脱离文档流,但不完全脱离,只是提升了半层;
    float了的元素和内联元素不支持margin:auto
  • 原文地址:https://www.cnblogs.com/wangxiaorui/p/5345148.html
Copyright © 2011-2022 走看看