what-the-bank/sources/okhttp3/internal/http/RealInterceptorChain.java

204 lines
7.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.internal.http;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import o.C14957gcv;
import okhttp3.Call;
import okhttp3.Connection;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Util;
import okhttp3.internal.connection.Exchange;
import okhttp3.internal.connection.RealCall;
/* loaded from: classes.dex */
public final class RealInterceptorChain implements Interceptor.Chain {
private final RealCall call;
private int calls;
private final int connectTimeoutMillis;
private final Exchange exchange;
private final int index;
private final List<Interceptor> interceptors;
private final int readTimeoutMillis;
private final Request request;
private final int writeTimeoutMillis;
/* JADX WARN: Multi-variable type inference failed */
public RealInterceptorChain(RealCall realCall, List<? extends Interceptor> list, int i, Exchange exchange, Request request, int i2, int i3, int i4) {
C14957gcv.e(realCall, "");
C14957gcv.e(list, "");
C14957gcv.e(request, "");
this.call = realCall;
this.interceptors = list;
this.index = i;
this.exchange = exchange;
this.request = request;
this.connectTimeoutMillis = i2;
this.readTimeoutMillis = i3;
this.writeTimeoutMillis = i4;
}
public static /* synthetic */ RealInterceptorChain copy$okhttp$default(RealInterceptorChain realInterceptorChain, int i, Exchange exchange, Request request, int i2, int i3, int i4, int i5, Object obj) {
if ((i5 & 1) != 0) {
i = realInterceptorChain.index;
}
if ((i5 & 2) != 0) {
exchange = realInterceptorChain.exchange;
}
Exchange exchange2 = exchange;
if ((i5 & 4) != 0) {
request = realInterceptorChain.request;
}
Request request2 = request;
if ((i5 & 8) != 0) {
i2 = realInterceptorChain.connectTimeoutMillis;
}
int i6 = i2;
if ((i5 & 16) != 0) {
i3 = realInterceptorChain.readTimeoutMillis;
}
int i7 = i3;
if ((i5 & 32) != 0) {
i4 = realInterceptorChain.writeTimeoutMillis;
}
return realInterceptorChain.copy$okhttp(i, exchange2, request2, i6, i7, i4);
}
public final RealInterceptorChain copy$okhttp(int i, Exchange exchange, Request request, int i2, int i3, int i4) {
C14957gcv.e(request, "");
return new RealInterceptorChain(this.call, this.interceptors, i, exchange, request, i2, i3, i4);
}
@Override // okhttp3.Interceptor.Chain
public final Connection connection() {
Exchange exchange = this.exchange;
return exchange == null ? null : exchange.getConnection$okhttp();
}
@Override // okhttp3.Interceptor.Chain
public final Interceptor.Chain withConnectTimeout(int i, TimeUnit timeUnit) {
C14957gcv.e(timeUnit, "");
if (this.exchange != null) {
throw new IllegalStateException("Timeouts can't be adjusted in a network interceptor".toString());
}
return copy$okhttp$default(this, 0, null, null, Util.checkDuration("connectTimeout", i, timeUnit), 0, 0, 55, null);
}
@Override // okhttp3.Interceptor.Chain
public final Interceptor.Chain withReadTimeout(int i, TimeUnit timeUnit) {
C14957gcv.e(timeUnit, "");
if (this.exchange != null) {
throw new IllegalStateException("Timeouts can't be adjusted in a network interceptor".toString());
}
return copy$okhttp$default(this, 0, null, null, 0, Util.checkDuration("readTimeout", i, timeUnit), 0, 47, null);
}
@Override // okhttp3.Interceptor.Chain
public final Interceptor.Chain withWriteTimeout(int i, TimeUnit timeUnit) {
C14957gcv.e(timeUnit, "");
if (this.exchange != null) {
throw new IllegalStateException("Timeouts can't be adjusted in a network interceptor".toString());
}
return copy$okhttp$default(this, 0, null, null, 0, 0, Util.checkDuration("writeTimeout", i, timeUnit), 31, null);
}
@Override // okhttp3.Interceptor.Chain
public final Call call() {
return this.call;
}
@Override // okhttp3.Interceptor.Chain
public final Response proceed(Request request) throws IOException {
C14957gcv.e(request, "");
if (this.index >= this.interceptors.size()) {
throw new IllegalStateException("Check failed.".toString());
}
this.calls++;
Exchange exchange = this.exchange;
if (exchange != null) {
if (!exchange.getFinder$okhttp().sameHostAndPort(request.url())) {
StringBuilder sb = new StringBuilder("network interceptor ");
sb.append(this.interceptors.get(this.index - 1));
sb.append(" must retain the same host and port");
throw new IllegalStateException(sb.toString().toString());
}
if (this.calls != 1) {
StringBuilder sb2 = new StringBuilder("network interceptor ");
sb2.append(this.interceptors.get(this.index - 1));
sb2.append(" must call proceed() exactly once");
throw new IllegalStateException(sb2.toString().toString());
}
}
RealInterceptorChain copy$okhttp$default = copy$okhttp$default(this, this.index + 1, null, request, 0, 0, 0, 58, null);
Interceptor interceptor = this.interceptors.get(this.index);
Response intercept = interceptor.intercept(copy$okhttp$default);
if (intercept == null) {
StringBuilder sb3 = new StringBuilder("interceptor ");
sb3.append(interceptor);
sb3.append(" returned null");
throw new NullPointerException(sb3.toString());
}
if (this.exchange != null) {
if (this.index + 1 < this.interceptors.size() && copy$okhttp$default.calls != 1) {
StringBuilder sb4 = new StringBuilder("network interceptor ");
sb4.append(interceptor);
sb4.append(" must call proceed() exactly once");
throw new IllegalStateException(sb4.toString().toString());
}
}
if (intercept.body() != null) {
return intercept;
}
StringBuilder sb5 = new StringBuilder("interceptor ");
sb5.append(interceptor);
sb5.append(" returned a response with no body");
throw new IllegalStateException(sb5.toString().toString());
}
@Override // okhttp3.Interceptor.Chain
public final int writeTimeoutMillis() {
return this.writeTimeoutMillis;
}
@Override // okhttp3.Interceptor.Chain
public final Request request() {
return this.request;
}
@Override // okhttp3.Interceptor.Chain
public final int readTimeoutMillis() {
return this.readTimeoutMillis;
}
public final int getWriteTimeoutMillis$okhttp() {
return this.writeTimeoutMillis;
}
public final Request getRequest$okhttp() {
return this.request;
}
public final int getReadTimeoutMillis$okhttp() {
return this.readTimeoutMillis;
}
public final Exchange getExchange$okhttp() {
return this.exchange;
}
public final int getConnectTimeoutMillis$okhttp() {
return this.connectTimeoutMillis;
}
public final RealCall getCall$okhttp() {
return this.call;
}
@Override // okhttp3.Interceptor.Chain
public final int connectTimeoutMillis() {
return this.connectTimeoutMillis;
}
}