只要我添加 request:willRedirectToUrl:
委托(delegate)中的方法请求停止从重定向的 url 下载,如果我不实现它继续从新 url 下载文件的方法。快把我逼疯了,为什么会这样?
最佳答案
如果您实现委托(delegate) willRedirectToUrl,则委托(delegate)可以完全控制重定向将发生的情况,因此它需要采取必要的措施 - 从 .h:
// Called on the delegate (if implemented) when the request receives a Location header and shouldRedirect is YES
// The delegate can then change the url if needed, and can restart the request by calling [request redirectToURL:], or simply cancel it
所以你只需要打电话:
// Can be called by delegates from inside their willRedirectSelector implementations to restart the request with a new url
- (void)redirectToURL:(NSURL *)newURL;
传递新的URL。
关于objective-c - ASIHTTPRequest 在请求 :willRedirectToUrl: is implemented 时停止下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8688919/