package okhttp3.internal.connection;

import java.io.IOException;
import kotlin.jvm.internal.o;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import okhttp3.internal.http.RealInterceptorChain;

/* JADX INFO: loaded from: classes3.dex */
public final class ConnectInterceptor implements Interceptor {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final ConnectInterceptor f22285a = new ConnectInterceptor();

    private ConnectInterceptor() {
    }

    @Override // okhttp3.Interceptor
    public final Response a(RealInterceptorChain realInterceptorChain) throws IOException {
        RealCall realCall = realInterceptorChain.f22384a;
        realCall.getClass();
        synchronized (realCall) {
            try {
                if (!realCall.f22328p) {
                    throw new IllegalStateException("released");
                }
                if (realCall.f22327o) {
                    throw new IllegalStateException("Check failed.");
                }
                if (realCall.f22326n) {
                    throw new IllegalStateException("Check failed.");
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        ExchangeFinder exchangeFinder = realCall.f22324k;
        o.e(exchangeFinder);
        OkHttpClient client = realCall.f22317a;
        o.h(client, "client");
        try {
            Exchange exchange = new Exchange(realCall, realCall.f22320d, exchangeFinder, exchangeFinder.a(realInterceptorChain.f22389f, client.f22077f, !o.c(realInterceptorChain.f22388e.f22126b, "GET"), realInterceptorChain.f22390g, realInterceptorChain.f22391h).j(client, realInterceptorChain));
            realCall.f22325m = exchange;
            realCall.f22330r = exchange;
            synchronized (realCall) {
                realCall.f22326n = true;
                realCall.f22327o = true;
            }
            if (realCall.f22329q) {
                throw new IOException("Canceled");
            }
            return RealInterceptorChain.a(realInterceptorChain, 0, exchange, null, 61).b(realInterceptorChain.f22388e);
        } catch (IOException e6) {
            exchangeFinder.c(e6);
            throw new RouteException(e6);
        } catch (RouteException e7) {
            exchangeFinder.c(e7.f22365b);
            throw e7;
        }
    }
}
