“太多的HTTP重定向"在使用Alamofire上传多部分表单数据时 [英] "too many HTTP redirects" while using Alamofire Upload Multipart Form Data

查看:236
本文介绍了“太多的HTTP重定向"在使用Alamofire上传多部分表单数据时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Alamofire 3并遇到此问题:

I'm using Alamofire 3 and encountered this:

[Result]: FAILURE: Error Domain=NSURLErrorDomain Code=-1007 "too many HTTP redirects" UserInfo={NSUnderlyingError=0x15eb422d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1007 "(null)"}, NSErrorFailingURLStringKey=URL omitted, NSErrorFailingURLKey= URL omitted, NSLocalizedDescription= too many HTTP redirects}

同时调用此方法:

upload(.POST, kTaskSubmitImageUrl, multipartFormData: { multipartFormData in
            multipartFormData.appendBodyPart(data: result, name: "uploaded")
            },
            encodingCompletion:{ encodingResult in

                switch encodingResult
                {
                    case .Success(let upload, _, _):
                        upload.responseJSON{
                            responseData in
                            debugPrint(responseData)
                        }
                    case .Failure(let errorStatus) :
                        debugPrint(errorStatus)
                }
            }
        )

有人知道这是怎么回事吗?我应该看看我的服务器吗?

anybody know whats going on about it? Should I look at my server?

推荐答案

事实证明,在iOS 9中,有此应用传输安全性(ATS)可以在应用与其后端之间的安全连接中实施最佳实践.因此,重定向问题.

it turns out that in iOS 9, there's this App Transport Security (ATS) to enforce best practices in secure connections between an app and its back end. Hence the redirect issues.

通过添加Alamofire.Manager.sharedInstance.delegate.taskWillPerformHTTPRedirection = nil

一切都像魔术XD一样

欢呼

Des

这篇关于“太多的HTTP重定向"在使用Alamofire上传多部分表单数据时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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