gpt4 book ai didi

ios - 不应该调用 Alamofire 4.0 RequestRetrier(_,retry,with,completion)

转载 作者:IT王子 更新时间:2023-10-29 05:22:26 25 4
gpt4 key购买 nike

我正在使用 Alamofire 4.0 的 RequestRetrier 来控制对过期访问 token 的请求的重试。我正在关注文档 here .

我有一个与文档 OAuth2Handler 中提供的示例非常相似的实现,它实现了 RequestAdapterRequestRetrier

我遇到的问题是 func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion) 从未被调用。 RequestAdapter 实现的 adapt 方法确实被调用了。

调试,看到SessionDelegate只在出错的时候调用了should(_,retry,with,completion),但是request返回的是Authorization相关的状态码问题,似乎不会产生错误,因此永远不会调用该方法。

我是不是漏掉了什么?

最佳答案

也许您没有收到错误。 Alamofire 不会将 400 次响应视为错误。如果您希望在收到 400 代码时出错,您应该将 validate() 链接到请求。如果是这种情况,您可以找到更多信息 here .

关于ios - 不应该调用 Alamofire 4.0 RequestRetrier(_,retry,with,completion),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39598030/

25 4 0