问题
This issue comes when i load website into webview of my cocoa application. my issue description:
Error Domain=NSURLErrorDomain Code=-1007 "too many HTTP redirects" UserInfo=0x18d17d56{NSErrorFailingURLStringKey=URLHERE, NSErrorFailingURLKey=URLHERE,NSLocalizedDescription=too many HTTP redirects}
why this error comes
how to handle it
i go though following links but does't help me
Too many HTTP redirects
"too many HTTP redirects" while using Alamofire Upload Multipart Form Data
too many HTTP redirects, Google Drive, iOS SDK and many more..
UPDATE:
- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
if(redirectResponse)
{
if([redirectResponse.URL.absoluteString isEqualToString:self.webviewLoadingURL.absoluteString])
{
NSLog(@"both redirect and load url is same");
}
}
return request;
}
I getting same url for redirect and load in webview.
回答1:
This is almost invariably caused by a server configuration error that causes the web page to redirect to itself (possibly by way of another intermediate URL). There's probably nothing you can do to fix this on the client side unless the problem is caused by your client code requesting an invalid/incorrect URL.
If you're asking how to present the error to the user, I would say that you should treat it in the same way that you'd treat a 404. That URL isn't likely to start working any time soon.
回答2:
I had this happen on an iPhone XS. It reported "too many HTTP redirects" only for a specific url no matter what I did. Even without an internet connection! Removing the app and reinstalling it solved the problem.
来源:https://stackoverflow.com/questions/38702529/how-to-handle-too-many-http-redirects-error