title: Unable to receive the URL for the last redirect for a GET request ios
body: <p><strong>What I want to do:</strong></p>
  
  <p>When I make a <code>GET</code> request to a URL, the response is a <code>302 HTTP response</code>, which means its a redirect. I know that there are multiple redirects(3 to 4) after my initial <code>GET</code> request. I want to get the very last URL after multiple redirects happen. I am only able to receive the first redirect URL. </p>
  
  <p><strong>What I've tried</strong>, is answers on:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/16370109/afnetworking-get-redirect-url">AFNetworking -- get redirect URL</a></li>
  <li><a href="https://stackoverflow.com/questions/10783499/nsurlrequest-how-to-handle-a-redirected-post">NSURLRequest: How to handle a redirected post?</a> </li>
  <li><a href="https://stackoverflow.com/questions/10577690/get-the-last-redirected-url-in-ios-5">Get the last redirected url in iOS 5?</a></li>
  <li><a href="https://stackoverflow.com/questions/1952219/iphone-nsurl-get-last-redirected-url">iPhone NSURL get last redirected url</a></li>
  </ul>
  
  <p>My code sniplet taken from the answers:</p>
  
  <pre><code>AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  NSString *URLString = @"URL";
  NSDictionary *parameters = @{@"k1": @"v1", @"k2": @"v2"};
  NSMutableURLRequest *request_orig = [manager.requestSerializer requestWithMethod:@"GET" URLString:[[NSURL URLWithString:URLString relativeToURL:manager.baseURL] absoluteString] parameters:parameters error:nil];
  
  AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request_orig];
  
  [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
  {
       //This is the first Redirect URL that I receive 
       NSLog(@"New redirect URL: %@",[[[operation response] URL] absoluteString]);
  } failure:^(AFHTTPRequestOperation *operation, NSError *error)
  {
       NSLog(@"Failure: err: %@", error);
  }];
  
  
  [operation setRedirectResponseBlock:^NSURLRequest *(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse) {
  
      if (redirectResponse) {
          NSMutableURLRequest *r = [request_orig mutableCopy]; // original request
          [r setURL: [request URL]];
          return r;
      } else {
          NSLog(@"redirecting to : %@", [request URL]);
          return request;
      }        
  }];
  
  [manager.operationQueue addOperation:operation];
  </code></pre>
  
  <p>I am able to receive the first redirected URL but there is no 2nd or 3rd redirect after that. What should I do in order to let the redirects continue and only receive the URL for the last redirect that is made. I am novice in iOS dev. I'll appreciate your help. Thanks.  </p>