如何处理“太多的HTTP重定向”?错误 [英] How to handle "too many HTTP redirects" Error

查看:897
本文介绍了如何处理“太多的HTTP重定向”?错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将网站加载到可可应用程序的webview中时,就会出现此问题。
我的问题描述:

This issue comes when i load website into webview of my cocoa application. my issue description:


Error Domain = NSURLErrorDomain代码= -1007 HTTP重定向过多
UserInfo = 0x18d17d56 {NSErrorFailingURLStringKey = URLHERE,
NSErrorFailingURLKey = URLHERE,NSLocalizedDescription =太多HTTP
重定向}

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

HTTP重定向过多

HTTP重定向过多;在使用Alamofire上传多部分表单数据时

太多的HTTP重定向,Google Drive,iOS SDK 等等。

更新:

- (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;
}

我在重定向和加载到Webview中使用相同的URL。

I getting same url for redirect and load in webview.

推荐答案

这几乎总是由服务器配置错误引起的,该错误导致网页重定向到自身(可能是通过另一个中间URL)。除非问题是由您的客户端代码请求无效/不正确的URL引起的,否则您可能无法在客户端上解决此问题。

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.

如果您询问如何为了向用户呈现错误,我想你应该像对待404一样对待它。该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.

这篇关于如何处理“太多的HTTP重定向”?错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆