1

Since today I've got some serious problems with AFNetworking requesting an https link where I want to get back some XML-Info, yesterday it already worked and I also sent out some TestFlight-Links, so it's very frustrating. I also didn't do any changes to the server configuration.

But today I'm just getting the error -1007 "too many http redirects". Did someone also had a problem like this? I already saw a post of iOS 9: "too many HTTP redirects" while using Alamofire Upload Multipart Form Data But I can't find this property they are talking of. Can someone help me please? Here is the configuration of the data task im doing for getting my response-XML, hope this helps.

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy
                                     timeoutInterval:35];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];    

showNetworkActivityIndicator();
manager.responseSerializer = [AFHTTPResponseSerializer serializer];


NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (error) {
        // Log error object
        NSLog(@"AFNetworking error response: %@\n\n\n", error);

    } else {
 //       NSLog(@"%@ %@", response, responseObject);

        NSString *responseString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

    }
}];
[dataTask resume];

thanks for help! best regards

Community
  • 1
  • 1
Manuel0595
  • 13
  • 6
  • What URL are you going to? The error seems straightforward - the URL you're hitting is redirecting you too many times. – kpsharp Feb 02 '16 at 20:36
  • I know the errortext says everything - but we haven't changed anxthing in the background everything is like before the error occured. like I said it worked the day before and in the browser everything works fine :-S – Manuel0595 Feb 03 '16 at 16:49
  • oh yes - a https url, I'm not allowed to post this here because of the restrictions the customer maid, but I can send it in a private message? – Manuel0595 Feb 03 '16 at 16:51

1 Answers1

3

I had the same problem, occurred when I tried to send request when server was unavailable. Then when server comes alive - this error occured.

This helped me:

URLCache.shared.removeAllCachedResponses()
  • This did solve my problem, however, my concern is, since URLCache is from Foundation, if i consistently remove all cachedresponse, how will that affect other networking service (a.k.a kingfisher)? – Happiehappie Apr 18 '19 at 09:57