“太多的HTTP重定向"在使用Alamofire上传多部分表单数据时

编程入门 行业动态 更新时间:2024-10-23 13:32:05
本文介绍了“太多的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上传多部分表单数据时

本文发布于:2023-11-26 17:21:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634490.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:太多   表单   重定向   上传   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!