- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
260 lines
10 KiB
Java
260 lines
10 KiB
Java
package com.mbridge.msdk.thrid.okhttp;
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.NamedRunnable;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.Util;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.cache.CacheInterceptor;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.connection.ConnectInterceptor;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.connection.StreamAllocation;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.http.BridgeInterceptor;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.http.CallServerInterceptor;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.http.RealInterceptorChain;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.http.RetryAndFollowUpInterceptor;
|
|
import com.mbridge.msdk.thrid.okhttp.internal.platform.Platform;
|
|
import com.mbridge.msdk.thrid.okio.AsyncTimeout;
|
|
import com.mbridge.msdk.thrid.okio.Timeout;
|
|
import java.io.IOException;
|
|
import java.io.InterruptedIOException;
|
|
import java.util.ArrayList;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.RejectedExecutionException;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes4.dex */
|
|
final class RealCall implements Call {
|
|
final OkHttpClient client;
|
|
private EventListener eventListener;
|
|
private boolean executed;
|
|
final boolean forWebSocket;
|
|
final Request originalRequest;
|
|
final RetryAndFollowUpInterceptor retryAndFollowUpInterceptor;
|
|
final AsyncTimeout timeout;
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public Request request() {
|
|
return this.originalRequest;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public Timeout timeout() {
|
|
return this.timeout;
|
|
}
|
|
|
|
private RealCall(OkHttpClient okHttpClient, Request request, boolean z) {
|
|
this.client = okHttpClient;
|
|
this.originalRequest = request;
|
|
this.forWebSocket = z;
|
|
this.retryAndFollowUpInterceptor = new RetryAndFollowUpInterceptor(okHttpClient, z);
|
|
AsyncTimeout asyncTimeout = new AsyncTimeout() { // from class: com.mbridge.msdk.thrid.okhttp.RealCall.1
|
|
@Override // com.mbridge.msdk.thrid.okio.AsyncTimeout
|
|
public void timedOut() {
|
|
RealCall.this.cancel();
|
|
}
|
|
};
|
|
this.timeout = asyncTimeout;
|
|
asyncTimeout.timeout(okHttpClient.callTimeoutMillis(), TimeUnit.MILLISECONDS);
|
|
}
|
|
|
|
public static RealCall newRealCall(OkHttpClient okHttpClient, Request request, boolean z) {
|
|
RealCall realCall = new RealCall(okHttpClient, request, z);
|
|
realCall.eventListener = okHttpClient.eventListenerFactory().create(realCall);
|
|
return realCall;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public Response execute() throws IOException {
|
|
synchronized (this) {
|
|
if (this.executed) {
|
|
throw new IllegalStateException("Already Executed");
|
|
}
|
|
this.executed = true;
|
|
}
|
|
captureCallStackTrace();
|
|
this.timeout.enter();
|
|
this.eventListener.callStart(this);
|
|
try {
|
|
try {
|
|
this.client.dispatcher().executed(this);
|
|
Response responseWithInterceptorChain = getResponseWithInterceptorChain();
|
|
if (responseWithInterceptorChain != null) {
|
|
return responseWithInterceptorChain;
|
|
}
|
|
throw new IOException("Canceled");
|
|
} catch (IOException e) {
|
|
IOException timeoutExit = timeoutExit(e);
|
|
this.eventListener.callFailed(this, timeoutExit);
|
|
throw timeoutExit;
|
|
}
|
|
} finally {
|
|
this.client.dispatcher().finished(this);
|
|
}
|
|
}
|
|
|
|
public IOException timeoutExit(IOException iOException) {
|
|
if (!this.timeout.exit()) {
|
|
return iOException;
|
|
}
|
|
InterruptedIOException interruptedIOException = new InterruptedIOException("timeout");
|
|
if (iOException != null) {
|
|
interruptedIOException.initCause(iOException);
|
|
}
|
|
return interruptedIOException;
|
|
}
|
|
|
|
private void captureCallStackTrace() {
|
|
this.retryAndFollowUpInterceptor.setCallStackTrace(Platform.get().getStackTraceForCloseable("response.body().close()"));
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public void enqueue(Callback callback) {
|
|
synchronized (this) {
|
|
if (this.executed) {
|
|
throw new IllegalStateException("Already Executed");
|
|
}
|
|
this.executed = true;
|
|
}
|
|
captureCallStackTrace();
|
|
this.eventListener.callStart(this);
|
|
this.client.dispatcher().enqueue(new AsyncCall(callback));
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public void cancel() {
|
|
this.retryAndFollowUpInterceptor.cancel();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public synchronized boolean isExecuted() {
|
|
return this.executed;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
public boolean isCanceled() {
|
|
return this.retryAndFollowUpInterceptor.isCanceled();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.Call
|
|
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
|
|
public RealCall m3721clone() {
|
|
return newRealCall(this.client, this.originalRequest, this.forWebSocket);
|
|
}
|
|
|
|
public StreamAllocation streamAllocation() {
|
|
return this.retryAndFollowUpInterceptor.streamAllocation();
|
|
}
|
|
|
|
public final class AsyncCall extends NamedRunnable {
|
|
static final /* synthetic */ boolean $assertionsDisabled = false;
|
|
private final Callback responseCallback;
|
|
|
|
public RealCall get() {
|
|
return RealCall.this;
|
|
}
|
|
|
|
public AsyncCall(Callback callback) {
|
|
super("OkHttp %s", RealCall.this.redactedUrl());
|
|
this.responseCallback = callback;
|
|
}
|
|
|
|
public String host() {
|
|
return RealCall.this.originalRequest.url().host();
|
|
}
|
|
|
|
public Request request() {
|
|
return RealCall.this.originalRequest;
|
|
}
|
|
|
|
public void executeOn(ExecutorService executorService) {
|
|
try {
|
|
try {
|
|
executorService.execute(this);
|
|
} catch (RejectedExecutionException e) {
|
|
InterruptedIOException interruptedIOException = new InterruptedIOException("executor rejected");
|
|
interruptedIOException.initCause(e);
|
|
RealCall.this.eventListener.callFailed(RealCall.this, interruptedIOException);
|
|
this.responseCallback.onFailure(RealCall.this, interruptedIOException);
|
|
RealCall.this.client.dispatcher().finished(this);
|
|
}
|
|
} catch (Throwable th) {
|
|
RealCall.this.client.dispatcher().finished(this);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.thrid.okhttp.internal.NamedRunnable
|
|
public void execute() {
|
|
boolean z;
|
|
Throwable th;
|
|
IOException e;
|
|
RealCall.this.timeout.enter();
|
|
try {
|
|
try {
|
|
z = true;
|
|
try {
|
|
this.responseCallback.onResponse(RealCall.this, RealCall.this.getResponseWithInterceptorChain());
|
|
} catch (IOException e2) {
|
|
e = e2;
|
|
IOException timeoutExit = RealCall.this.timeoutExit(e);
|
|
if (!z) {
|
|
RealCall.this.eventListener.callFailed(RealCall.this, timeoutExit);
|
|
this.responseCallback.onFailure(RealCall.this, timeoutExit);
|
|
} else {
|
|
Platform.get().log(4, "Callback failure for " + RealCall.this.toLoggableString(), timeoutExit);
|
|
}
|
|
RealCall.this.client.dispatcher().finished(this);
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
RealCall.this.cancel();
|
|
if (!z) {
|
|
this.responseCallback.onFailure(RealCall.this, new IOException("canceled due to " + th));
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Throwable th3) {
|
|
RealCall.this.client.dispatcher().finished(this);
|
|
throw th3;
|
|
}
|
|
} catch (IOException e3) {
|
|
z = false;
|
|
e = e3;
|
|
} catch (Throwable th4) {
|
|
z = false;
|
|
th = th4;
|
|
}
|
|
RealCall.this.client.dispatcher().finished(this);
|
|
}
|
|
}
|
|
|
|
public String toLoggableString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(isCanceled() ? "canceled " : "");
|
|
sb.append(this.forWebSocket ? "web socket" : NotificationCompat.CATEGORY_CALL);
|
|
sb.append(" to ");
|
|
sb.append(redactedUrl());
|
|
return sb.toString();
|
|
}
|
|
|
|
public String redactedUrl() {
|
|
return this.originalRequest.url().redact();
|
|
}
|
|
|
|
public Response getResponseWithInterceptorChain() throws IOException {
|
|
ArrayList arrayList = new ArrayList();
|
|
arrayList.addAll(this.client.interceptors());
|
|
arrayList.add(this.retryAndFollowUpInterceptor);
|
|
arrayList.add(new BridgeInterceptor(this.client.cookieJar()));
|
|
arrayList.add(new CacheInterceptor(this.client.internalCache()));
|
|
arrayList.add(new ConnectInterceptor(this.client));
|
|
if (!this.forWebSocket) {
|
|
arrayList.addAll(this.client.networkInterceptors());
|
|
}
|
|
arrayList.add(new CallServerInterceptor(this.forWebSocket));
|
|
Response proceed = new RealInterceptorChain(arrayList, null, null, null, 0, this.originalRequest, this, this.eventListener, this.client.connectTimeoutMillis(), this.client.readTimeoutMillis(), this.client.writeTimeoutMillis()).proceed(this.originalRequest);
|
|
if (!this.retryAndFollowUpInterceptor.isCanceled()) {
|
|
return proceed;
|
|
}
|
|
Util.closeQuietly(proceed);
|
|
throw new IOException("Canceled");
|
|
}
|
|
}
|