title: Using AFNetworking on iOS, not getting a 302 status code in redirect
body: <p>I am using AFNetworking on iOS and trying to access webpage that gives me a 302 status code, redirects me and then a 200 when the redirected page loads.</p>
  
  <p>However, I am unable to capture this in my iOS app. I tried adding the authenticationChallenge block but it doesn't get called. The completionBlock is getting the redirected view but a status code of 200 only. What am I missing here? I need to send login details when I get a 302 code. My code is pasted below:</p>
  
  <pre><code>  AFHTTPRequestOperation *uploadOperation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  [uploadOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id response) {
      NSLog(@"Request: %@", [operation.request description]);
      NSLog(@"CODE: %i",operation.response.statusCode);
      NSLog(@"Response: %@", [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]);
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
      self.statusLabel.text = @"upload failed";
  }];    
  
  [uploadOperation setAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
      NSLog(@"pls authenticate");
  }];
  </code></pre>