AFNetworking error too many http redirects iOS 9

不羁的心 提交于 2021-02-11 06:43:35

问题


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


回答1:


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()


来源:https://stackoverflow.com/questions/35162201/afnetworking-error-too-many-http-redirects-ios-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!