Note that there are some explanatory texts on larger screens.

plurals
  1. POPOST Request returning unwanted cached results (AFNetworking)
    text
    copied!<p>I'm using <a href="https://github.com/AFNetworking/AFNetworking" rel="nofollow">AFNetworking</a> to make POST requests from a shared "authenticator" class that passes in a user's username and password. Here is the POST request that I make:</p> <pre><code> NSURL *url = [NSURL URLWithString:@"https://www..."]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; // params NSDictionary* dict = @{@"loginName": username, @"password": password, @"serviceName": @"...", @"serviceURL": @"...", @"action": @"..."}; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; request = [httpClient requestWithMethod:@"POST" path:@"..." parameters:dict]; request.cachePolicy = NSURLRequestReloadIgnoringCacheData; request.timeoutInterval = 30.0; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"%@", operation.responseString); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"login failed"); }]; [operation start]; </code></pre> <p>It works very well for the first login and everything returns as expected. When I attempt to login with a different username/password, I see that the output of the <code>operation.responseString</code> is the exact same output as the first login.</p> <p>Does anyone know why it is returning the output from the first login? I feel that the response is a cached response and I had added the following to try to prevent the return of cached information:</p> <pre><code>request.cachePolicy = NSURLRequestReloadIgnoringCacheData; </code></pre> <p>I have set breakpoints to see that the username and password in the <code>NSDictionary</code> for the parameters are the new username/password combination.</p> <p>The string literals are not manipulated in anyway as well and are the same in every POST request. The elipses are for privacy and are placeholders for strings with semantic meaning.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload