当收到302 AWS的S3 NSURLSessionDownloadTask被取消:AFNetworking 2.0 [英] AFNetworking 2.0: NSURLSessionDownloadTask is cancelled when received 302 to AWS S3

查看:1212
本文介绍了当收到302 AWS的S3 NSURLSessionDownloadTask被取消:AFNetworking 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的README文件(从AFNetworking 2.0页)一个简单的例子来下载图像。一切工作正常的图像提供直接从我的网站,断绝。 但是,对于那些位于S3的web服务器返回302重定向以下错误:

I'm using a simple example from the README file (from AFNetworking 2.0 page) to download an image. All works fine for the images served directly from my web-sever. But for those located on the S3 the web-server returns 302 Redirect the following error:

Error Domain=NSURLErrorDomain Code=-999 "cancelled"

当我试图从S3下载图像(使用相同的code)直接(忽略重定向)我收到同样的错误。

When I try to download the image (using the same code) directly from the S3 (omitting the redirection) I receive the same error.

我已经检查了wget的实际图像的可用性。该图像是公开可用( https://youguide.s3.amazonaws.com/icons/user_96x96巴纽)。

I've checked the availability of the actual image with wget. The image is publicly available (https://youguide.s3.amazonaws.com/icons/user_96x96.png).

任何人都遇到类似的问题?

Anyone experience the similar problem?

推荐答案

我有同样的问题与S3,似乎已经解决了。 AFNetworking是在被取消请求认证挑战处理逻辑返回一个值

I was having the same problem with S3 and seem to have resolved it. AFNetworking was returning a value in the authentication challenge handling logic that was canceling the request.

通过告诉 AFURLSessionManager 如何处理我已经解决了这一问题验证挑战。

By telling the AFURLSessionManager how to handle authentication challenges I've fixed the problem.

[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition (NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential) {
    return NSURLSessionAuthChallengePerformDefaultHandling;
}];

这篇关于当收到302 AWS的S3 NSURLSessionDownloadTask被取消:AFNetworking 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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