shouldRetry

abstract fun shouldRetry(request: HttpRequest, consecutiveRetryCount: Int, result: NetworkResult): RetryPolicy

Determines if a network request should be retried based on the provided parameters. An interceptor that only observes results returns RetryPolicy.DoNotRetry.

Interceptors are asked in reverse order of insertion, and the first one returning a RetryPolicy that retries decides the retry; RetryPolicy.DoNotRetry means this interceptor has no opinion, so the next one is asked. No interceptor is asked once the client's maxRetryCount, if any, has been reached (see NetworkClient.newClient).

Return

A RetryPolicy indicating whether the request should be retried and the retry behavior.

Parameters

request

The HttpRequest object representing the request.

consecutiveRetryCount

The number of consecutive retries this interceptor proposed for this request. It is 0 on this interceptor's first proposal, and is reset to 0 after another interceptor proposed a retry.

result

The NetworkResult object representing the result of the previous request attempt.