问题
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