RetryInterceptor

class RetryInterceptor(maxRetries: Int) : Interceptor

OkHttp interceptor that retries a request after a transport failure (IOException) or an HTTP 5xx response. 4xx responses are returned without retrying.

Used by SceneFormContext.callGameAPI with maxRetries = 3, on a client created per call.

Note: the retry counter is a field of the interceptor and is never reset, so one instance allows at most maxRetries retries over its whole lifetime, not per request.

Parameters

maxRetries

Maximum number of extra attempts.

Constructors

Link copied to clipboard
constructor(maxRetries: Int)

Functions

Link copied to clipboard
open override fun intercept(chain: Interceptor.Chain): Response

Proceeds with the request and retries while the attempt failed with an IOException or returned 5xx and retries remain; the body of a discarded 5xx response is closed.