码迷,mamicode.com
首页 > Web开发 > 详细

AFNetworking2.x 使用过程中遇到的问题

时间:2017-05-10 11:30:23      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:sse   rdo   setw   type   pwd   operation   objc   下标   task   

1.//以下写一下关于AFNetworking2.0的GET数据请求问题。刚開始的时候没有写以下标红的代码,所以导致有一个问题。错误显演示样例如以下:

Error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x913a3b0 
{NSErrorFailingURLKey=http://192.168.1.160/mm/app/index.php?com=com_appService&method=save&app_com=com_passport&task=app_doLogin&
ID=ceshi008&PWD=E10ADC3949BA59ABBE56E057F20F883E&devices_type=ios&devices_token=f32ba695aa7e7a395e862784780efae47740c9498d999ee5cc
8f3b34a14d3b96, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x9060f30> { URL: http://192.168.1.160/mm/app
/index.php?com=com_appService&method=save&app_com=com_passport&task=app_doLogin&ID=ceshi008&PWD=E10ADC3949BA59ABBE56E057F20F883E&d
evices_type=ios&devices_token=f32ba695aa7e7a395e862784780efae47740c9498d999ee5cc8f3b34a14d3b96 } { status code: 200, headers {
    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = "Keep-Alive";
    "Content-Length" = 83;
    "Content-Type" = "text/html; charset=utf-8";
    Date = "Fri, 23 May 2014 01:53:49 GMT";
    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
    "Keep-Alive" = "timeout=5, max=100";
    Pragma = "no-cache";
    Server = "Apache/2.2.9 (APMServ) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.6";
    "Set-Cookie" = "PHPSESSID=6b6581c54a5301bcc1808696e83eab52; path=/";
    "X-Powered-By" = "PHP/5.2.6";
} }, NSLocalizedDescription=Request failed: unacceptable content-type: "text/html"}



AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [manager GET:@"<del>http://192.168.1.160/mm/app/index.php?com=com_appService&method=save&app_com=com_passport&task=app_doLogin&
ID=ceshi008&PWD=E10ADC3949BA59ABBE56E057F20F883E&devices_type=ios&devices_token=f32ba695aa7e7a395e862784780efae47740c9498d999ee5cc
8f3b34a14d3b96</del>" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"JSON: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];
2.关于POST请求也存在同样的问题。我这里没有真实測试。仅仅是简单測了一下,貌似能够,跟上面的问题是一样的解决方法。


AFNetworking2.x 使用过程中遇到的问题

标签:sse   rdo   setw   type   pwd   operation   objc   下标   task   

原文地址:http://www.cnblogs.com/zhchoutai/p/6834587.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!