Reputation: 29
How to check if the response is returned :
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.5.6
Date: Wed, 18 Mar 2015 19:23:02 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Last-Modified: Wed, 18 Mar 2015 19:23:02 GMT
Set-Cookie: PHPSESSID=1oh16nbnn9anin3r71tcsmo804; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: er_referer=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT
Set-Cookie: S_ID=1061662561; path=/
Location: /core/
request code :
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
AFHTTPRequestSerializer * requestSerializer = [AFHTTPRequestSerializer serializer];
[requestSerializer setValue:ua forHTTPHeaderField:@"User-Agent"];
manager.requestSerializer = requestSerializer;
AFHTTPResponseSerializer * responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer = responseSerializer;
NSDictionary *parameters = @{@"login": myLogin, @"pass": myPassword};
[manager POST:urlLogin parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([operation.responseString rangeOfString:@""].location == NSNotFound) {
NSLog(@"Login or password false");
} else {
If the response html I'm doing like this if ([operation.responseString rangeOfString: @ "Then I put the titel"]. Location == NSNotFound)
, but do not know how to do in this case
Upvotes: 0
Views: 325
Reputation: 66244
The Foundation URL Loading System will automatically redirect your request to the path specified in the Location
header.
If you need to intercept the redirect, usually to handle an authentication issue, you can set an authentication challenge block (and if necessary, a redirect response block) on the operation
object.
Here's an AFNetworking GitHub issue in which this issue is discussed. It has some sample code if you need it.
Upvotes: 1