Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle "too many HTTP redirects" Error

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.

like image 863
S. S Avatar asked Oct 16 '25 04:10

S. S


2 Answers

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.

like image 74
Tom Avatar answered Oct 18 '25 00:10

Tom


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.

like image 41
dgatwood Avatar answered Oct 17 '25 23:10

dgatwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!