ios - AFNetworking 错误太多 http 重定向 iOS 9

标签 ios http redirect afnetworking

从今天开始,我在 AFNetworking 请求 https 链接时遇到了一些严重的问题,我想在其中取回一些 XML-Info,昨天它已经工作了,我还发送了一些 TestFlight-Links,所以这非常令人沮丧。我也没有对服务器配置进行任何更改。

但今天我收到错误 -1007“太多的 http 重定向”。有人也有这样的问题吗?我已经看到了 iOS 9 的帖子:"too many HTTP redirects" while using Alamofire Upload Multipart Form Data 但是我找不到他们所说的这个属性。 有人能帮助我吗? 这是我为获取响应 XML 而执行的数据任务的配置,希望对您有所帮助。

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy
                                     timeoutInterval:35];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];    

showNetworkActivityIndicator();
manager.responseSerializer = [AFHTTPResponseSerializer serializer];


NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (error) {
        // Log error object
        NSLog(@"AFNetworking error response: %@\n\n\n", error);

    } else {
 //       NSLog(@"%@ %@", response, responseObject);

        NSString *responseString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

    }
}];
[dataTask resume];

感谢帮助! 最好的问候

最佳答案

我有同样的问题,当我试图在服务器不可用时发送请求时发生。然后当服务器启动时 - 发生此错误。

这对我有帮助:

URLCache.shared.removeAllCachedResponses()

关于ios - AFNetworking 错误太多 http 重定向 iOS 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35162201/

相关文章:

PHP header 位置重定向在 iPhone 上不起作用

ios - 类扩展中的属性属性与主类不匹配

ios - IP 配置 apple80211 Open() 在 iOS8 上崩溃

security - 安全 header

flutter - 即使我使用 initState,页面加载时 API 数据仍为空

asp.net - web.config 将非 www 或非 https 重定向到 https ://www using rules

.htaccess - HTACCESS 重写在 Ubuntu 14、Apache2 上不起作用

iphone - 更改选定段控件的颜色

ios - 如何从 Objective C 项目 App Delegate 调用 Swift?

javascript - 单击一次触发 2 个帖子