public final class RetryAndFollowUpInterceptor extends java.lang.Object implements Interceptor
IOException
if the call was canceled.Interceptor.Chain
Modifier and Type | Field and Description |
---|---|
private OkHttpClient |
client |
private static int |
MAX_FOLLOW_UPS
How many redirects and auth challenges should we attempt? Chrome follows 21 redirects; Firefox,
curl, and wget follow 20; Safari follows 16; and HTTP/1.0 recommends 5.
|
Constructor and Description |
---|
RetryAndFollowUpInterceptor(OkHttpClient client) |
Modifier and Type | Method and Description |
---|---|
private Request |
followUpRequest(Response userResponse,
Route route)
Figures out the HTTP request to make in response to receiving
userResponse . |
Response |
intercept(Interceptor.Chain chain) |
private boolean |
isRecoverable(java.io.IOException e,
boolean requestSendStarted) |
private boolean |
recover(java.io.IOException e,
Transmitter transmitter,
boolean requestSendStarted,
Request userRequest)
Report and attempt to recover from a failure to communicate with a server.
|
private boolean |
requestIsOneShot(java.io.IOException e,
Request userRequest) |
private int |
retryAfter(Response userResponse,
int defaultDelay) |
private static final int MAX_FOLLOW_UPS
private final OkHttpClient client
public RetryAndFollowUpInterceptor(OkHttpClient client)
public Response intercept(Interceptor.Chain chain) throws java.io.IOException
intercept
in interface Interceptor
java.io.IOException
private boolean recover(java.io.IOException e, Transmitter transmitter, boolean requestSendStarted, Request userRequest)
e
is recoverable, or false if the failure is permanent. Requests with a body can only
be recovered if the body is buffered or if the failure occurred before the request has been
sent.private boolean requestIsOneShot(java.io.IOException e, Request userRequest)
private boolean isRecoverable(java.io.IOException e, boolean requestSendStarted)
private Request followUpRequest(Response userResponse, @Nullable Route route) throws java.io.IOException
userResponse
. This will
either add authentication headers, follow redirects or handle a client request timeout. If a
follow-up is either unnecessary or not applicable, this returns null.java.io.IOException
private int retryAfter(Response userResponse, int defaultDelay)