AFNetworking2.x 使用過程中遇到的問題
阿新 • • 發佈:2017-05-10
sport 存在 headers htm out 數據請求 下標 devices 一個
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 使用過程中遇到的問題