限制 Authenticator 的重试次数
Limit retry count of Authenticator
我扩展 Authenticator
以在收到身份验证质询 (401) 时检索授权和身份验证令牌。它重试 20 次。有没有办法设置不同的计数(我想将其设置为 3)?
为了以防万一,我将 OkHttp(3) 与 retrofit2 结合使用。
请参阅 Handling Authentication 文档:
private int responseCount(Response response) {
int result = 1;
while ((response = response.priorResponse()) != null) {
result++;
}
return result;
}
我扩展 Authenticator
以在收到身份验证质询 (401) 时检索授权和身份验证令牌。它重试 20 次。有没有办法设置不同的计数(我想将其设置为 3)?
为了以防万一,我将 OkHttp(3) 与 retrofit2 结合使用。
请参阅 Handling Authentication 文档:
private int responseCount(Response response) {
int result = 1;
while ((response = response.priorResponse()) != null) {
result++;
}
return result;
}