package okhttp3.internal.http; import java.util.List; import okhttp3.Call; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import okhttp3.internal.connection.Exchange; import okhttp3.internal.connection.Transmitter; /* loaded from: classes5.dex */ public final class RealInterceptorChain implements Interceptor.Chain { public final Call call; public int calls; public final int connectTimeout; public final Exchange exchange; public final int index; public final List interceptors; public final int readTimeout; public final Request request; public final Transmitter transmitter; public final int writeTimeout; @Override // okhttp3.Interceptor.Chain public int connectTimeoutMillis() { return this.connectTimeout; } @Override // okhttp3.Interceptor.Chain public int readTimeoutMillis() { return this.readTimeout; } @Override // okhttp3.Interceptor.Chain public Request request() { return this.request; } public Transmitter transmitter() { return this.transmitter; } @Override // okhttp3.Interceptor.Chain public int writeTimeoutMillis() { return this.writeTimeout; } public RealInterceptorChain(List list, Transmitter transmitter, Exchange exchange, int i, Request request, Call call, int i2, int i3, int i4) { this.interceptors = list; this.transmitter = transmitter; this.exchange = exchange; this.index = i; this.request = request; this.call = call; this.connectTimeout = i2; this.readTimeout = i3; this.writeTimeout = i4; } public Exchange exchange() { Exchange exchange = this.exchange; if (exchange != null) { return exchange; } throw new IllegalStateException(); } @Override // okhttp3.Interceptor.Chain public Response proceed(Request request) { return proceed(request, this.transmitter, this.exchange); } public Response proceed(Request request, Transmitter transmitter, Exchange exchange) { if (this.index >= this.interceptors.size()) { throw new AssertionError(); } this.calls++; Exchange exchange2 = this.exchange; if (exchange2 != null && !exchange2.connection().supportsUrl(request.url())) { throw new IllegalStateException("network interceptor " + this.interceptors.get(this.index - 1) + " must retain the same host and port"); } if (this.exchange != null && this.calls > 1) { throw new IllegalStateException("network interceptor " + this.interceptors.get(this.index - 1) + " must call proceed() exactly once"); } RealInterceptorChain realInterceptorChain = new RealInterceptorChain(this.interceptors, transmitter, exchange, this.index + 1, request, this.call, this.connectTimeout, this.readTimeout, this.writeTimeout); Interceptor interceptor = (Interceptor) this.interceptors.get(this.index); Response intercept = interceptor.intercept(realInterceptorChain); if (exchange != null && this.index + 1 < this.interceptors.size() && realInterceptorChain.calls != 1) { throw new IllegalStateException("network interceptor " + interceptor + " must call proceed() exactly once"); } if (intercept == null) { throw new NullPointerException("interceptor " + interceptor + " returned null"); } if (intercept.body() != null) { return intercept; } throw new IllegalStateException("interceptor " + interceptor + " returned a response with no body"); } }