onAttemptResult

open fun onAttemptResult(request: HttpRequest, retryCount: Int, result: NetworkResult)

Called with the result of every attempt of a request.

It is called on every interceptor, in insertion order, for every attempt, before any interceptor is asked to shouldRetry. The result may therefore still be retried: never assume that it is the final result of the request.

The default implementation does nothing.

Parameters

request

The HttpRequest of the attempt.

retryCount

The number of retries of this request sent before this attempt, 0 for the initial attempt. It counts the retries proposed by all the interceptors, unlike the consecutiveRetryCount of shouldRetry, and is not reset by a wait for connectivity. Once the client's maxRetryCount is reached, the last result still arrives here, with a retryCount equal to maxRetryCount. A result arriving after the request was disposed, or a queued attempt cancelled before it was sent, carries the count of its own attempt.

result

The NetworkResult of the attempt. Once a dispose of the request has taken effect on the Tealium background thread, the attempt in flight arrives as a NetworkResult.Failure of NetworkException.CancelledException, even if the server had already answered; a result processed before that arrives unchanged.