AFNetworking2.x 使用過程中遇到的問題

來源:互聯網
上載者:User

標籤:afnetworking   get   post   -1016   

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=f32ba695aa7e7a395e862784780efae47740c9498d999ee5cc8f3b34a14d3b96, 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&devices_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=f32ba695aa7e7a395e862784780efae47740c9498d999ee5cc8f3b34a14d3b96</del>" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {        NSLog(@"JSON: %@", responseObject);    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {        NSLog(@"Error: %@", error);    }];2.關於POST請求也存在相同的問題,我這裡沒有真實測試,只是簡單測了一下,貌似可以,跟上面的問題是一樣的解決方案。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.