Я запрашиваю свой сервер с помощью AFNetworking
, последней версии - на сегодняшний день.AFNetworking Получить полный ответ HTTP
Моя серверная часть PHP отправляет ошибку, связанную с PHP, но я не могу понять, что такое ошибка (поэтому я могу ее отлаживать), поскольку AFNetworking ожидает JSON.
Может ли кто-нибудь сказать мне, как я могу увидеть полный HTTP-результат. Я исследовал, и я знаю, что это связано с operation.responseString
внутри блока success
/fail
. Блок моего текущего блока не имеет AFHTTPRequestOperation* operation
, и я не могу добавить его как другую переменную блока.
Я бы очень признателен за помощь.
Следующий код использует
NSURL *url = [[NSURL alloc]initWithString:URL];
AFHTTPClient *httpClient = [[AFHTTPClient alloc]initWithBaseURL:url];
NSURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:URLPATH parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
{
//...
}
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
NSLog(@"Inside the success block %@",JSON);
[[self delegate ]shareExerciseDone:JSON];
[[self delegate] activityIndicatorFinish];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
NSLog(@"Response text is: %@", operation.responseString);
NSLog(@"json text is: %@", JSON);
NSLog(@"Request failed with error: %@, %@", error, error.userInfo);
[[self delegate] activityIndicatorFinish];
}];
[operation start];
Ошибка
Request failed with error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0xc1b4520 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}, {
NSDebugDescription = "JSON text did not start with array or object and option to allow fragments not set.";
Вы ищете 'response.statusCode' или' response.allHeaderFields'? [Документация NSHTTPURLResponse] (https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPURLResponse_Class/Reference/Reference.html) – danielbeard
Нет, мне нужен полный текст HTML, который выводится PHP. Я хочу посмотреть, где это не удается, и что посылает это не JSON. –