Alamofire 4.0 RequestRetrier不应该被调用(

编程入门 行业动态 更新时间:2024-10-27 06:25:59
本文介绍了Alamofire 4.0 RequestRetrier不应该被调用(_,retry,with,completion)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Alamofire 4.0的 RequestRetrier 来控制对过期访问令牌的请求的重试。我正在文档此处。

I am using the RequestRetrier of Alamofire 4.0 to control the retrying of requests for expired access token. I am following the documentation here.

我的实现与文档 OAuth2Handler 中提供的示例非常相似,该文档实现了 RequestAdapter 和 RequestRetrier 。

I have a very similar implementation to the example available in the documentation OAuth2Handler which implements RequestAdapter and RequestRetrier.

我遇到的问题是 func应该(_经理:SessionManager,重试请求:请求,错误:错误,完成:@转义RequestRetryCompletion)永远不会被调用。确实会调用 RequestAdapter 实现的 adapt 方法。

The issue I am encountering is that func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion) is never being called. The adapt method of the RequestAdapter implementation does get called though.

调试,我看到 SessionDelegate 仅在存在以下情况时调用应该(_,retry,with,completion)错误,但请求返回与授权问题相关的状态代码,似乎没有生成错误,因此该方法永远不会被调用。

Debugging, I see that SessionDelegate only calls should(_,retry,with,completion) when there is an error, but requests that return status codes related to Authorization issues, don't seem to generate errors, so that method never gets called.

我在这里错过了什么吗?

Am I missing something here?

推荐答案

也许您没有收到错误消息。 Alamofire 不会将400个响应视为错误。如果在接收400个代码时遇到错误,则应将 validate()链接到请求。 如果您是这种情况,可以在此处找到更多信息。

Maybe you are not getting an error. 400 responses aren't considered as error by Alamofire. In case you want get an error when receiving a 400 code you should chain validate() to the request. If this is your case you can find more information here.

更多推荐

Alamofire 4.0 RequestRetrier不应该被调用(

本文发布于:2023-11-26 06:05:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632936.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Alamofire   RequestRetrier

发布评论

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

>www.elefans.com

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