How to handle “too many HTTP redirects” Error

梦想的初衷 提交于 2020-08-11 08:40:50

问题


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

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