package p447.p448.p455;

import java.io.IOException;
import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import kotlin.TypeCastException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p402.InterfaceC6540;
import p402.p411.p413.C6635;
import p402.p420.C6703;
import p447.C6905;
import p447.C6908;
import p447.C6921;
import p447.C6926;
import p447.C6933;
import p447.EnumC6924;
import p447.p448.C6943;
import p447.p448.p452.C6968;
import p447.p448.p453.C6985;
import p447.p448.p453.C6987;
import p447.p448.p453.C6991;
import p447.p448.p453.InterfaceC6984;
import p461.C7108;
import p461.InterfaceC7127;
import p461.InterfaceC7129;

/* JADX INFO: renamed from: ސ.ޣ.އ.ކ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C7030 implements InterfaceC6984 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public volatile C7036 f20495;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final EnumC6924 f20496;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public volatile boolean f20497;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final C6968 f20498;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final C6987 f20499;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C7011 f20500;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public static final C7031 f20494 = new C7031(null);

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final List<String> f20492 = C6943.m10160("connection", "host", "keep-alive", "proxy-connection", "te", "transfer-encoding", "encoding", "upgrade", ":method", ":path", ":scheme", ":authority");

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final List<String> f20493 = C6943.m10160("connection", "host", "keep-alive", "proxy-connection", "te", "transfer-encoding", "encoding", "upgrade");

    /* JADX INFO: renamed from: ސ.ޣ.އ.ކ$֏, reason: contains not printable characters */
    public static final class C7031 {
        public C7031() {
        }

        public /* synthetic */ C7031(DefaultConstructorMarker defaultConstructorMarker) {
        }
    }

    public C7030(C6921 c6921, C6968 c6968, C6987 c6987, C7011 c7011) {
        if (c6921 == null) {
            C6635.m9824("client");
            throw null;
        }
        if (c6968 == null) {
            C6635.m9824("connection");
            throw null;
        }
        if (c6987 == null) {
            C6635.m9824("chain");
            throw null;
        }
        if (c7011 == null) {
            C6635.m9824("http2Connection");
            throw null;
        }
        this.f20498 = c6968;
        this.f20499 = c6987;
        this.f20500 = c7011;
        this.f20496 = c6921.f20077.contains(EnumC6924.H2_PRIOR_KNOWLEDGE) ? EnumC6924.H2_PRIOR_KNOWLEDGE : EnumC6924.HTTP_2;
    }

    @Override // p447.p448.p453.InterfaceC6984
    public void cancel() {
        this.f20497 = true;
        C7036 c7036 = this.f20495;
        if (c7036 != null) {
            c7036.m10328(EnumC7003.CANCEL);
        }
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ֏ */
    public long mo10250(C6933 c6933) {
        if (c6933 == null) {
            C6635.m9824("response");
            throw null;
        }
        if (C6985.m10262(c6933)) {
            return C6943.m10155(c6933);
        }
        return 0L;
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ֏ */
    public C6933.C6934 mo10251(boolean z) throws ProtocolException {
        C7036 c7036 = this.f20495;
        if (c7036 == null) {
            C6635.m9822();
            throw null;
        }
        C6905 c6905M10337 = c7036.m10337();
        C7031 c7031 = f20494;
        EnumC6924 enumC6924 = this.f20496;
        if (c7031 == null) {
            throw null;
        }
        if (c6905M10337 == null) {
            C6635.m9824("headerBlock");
            throw null;
        }
        if (enumC6924 == null) {
            C6635.m9824("protocol");
            throw null;
        }
        ArrayList arrayList = new ArrayList(20);
        int size = c6905M10337.size();
        C6991 c6991M10270 = null;
        for (int i = 0; i < size; i++) {
            String strM10068 = c6905M10337.m10068(i);
            String strM10070 = c6905M10337.m10070(i);
            if (C6635.m9825((Object) strM10068, (Object) ":status")) {
                c6991M10270 = C6991.f20343.m10270("HTTP/1.1 " + strM10070);
            } else if (f20493.contains(strM10068)) {
                continue;
            } else {
                if (strM10068 == null) {
                    C6635.m9824("name");
                    throw null;
                }
                if (strM10070 == null) {
                    C6635.m9824("value");
                    throw null;
                }
                arrayList.add(strM10068);
                arrayList.add(C6703.m9900(strM10070).toString());
            }
        }
        if (c6991M10270 == null) {
            throw new ProtocolException("Expected ':status' header not present");
        }
        C6933.C6934 c6934 = new C6933.C6934();
        c6934.f20160 = enumC6924;
        c6934.f20161 = c6991M10270.f20345;
        c6934.m10128(c6991M10270.f20346);
        Object[] array = arrayList.toArray(new String[0]);
        if (array == null) {
            throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
        }
        c6934.m10129(new C6905((String[]) array, null));
        if (z && c6934.f20161 == 100) {
            return null;
        }
        return c6934;
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ֏ */
    public InterfaceC7127 mo10252(C6926 c6926, long j) {
        if (c6926 == null) {
            C6635.m9824("request");
            throw null;
        }
        C7036 c7036 = this.f20495;
        if (c7036 != null) {
            return c7036.m10334();
        }
        C6635.m9822();
        throw null;
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ֏ */
    public void mo10253() {
        C7036 c7036 = this.f20495;
        if (c7036 != null) {
            c7036.m10334().close();
        } else {
            C6635.m9822();
            throw null;
        }
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ֏ */
    public void mo10254(C6926 c6926) throws IOException {
        if (c6926 == null) {
            C6635.m9824("request");
            throw null;
        }
        if (this.f20495 != null) {
            return;
        }
        boolean z = c6926.f20131 != null;
        if (f20494 == null) {
            throw null;
        }
        C6905 c6905 = c6926.f20130;
        ArrayList arrayList = new ArrayList(c6905.size() + 4);
        arrayList.add(new C7005(C7005.f20383, c6926.f20129));
        C7108 c7108 = C7005.f20384;
        C6908 c6908 = c6926.f20128;
        if (c6908 == null) {
            C6635.m9824("url");
            throw null;
        }
        String strM10081 = c6908.m10081();
        String strM10084 = c6908.m10084();
        if (strM10084 != null) {
            strM10081 = strM10081 + '?' + strM10084;
        }
        arrayList.add(new C7005(c7108, strM10081));
        String strM10115 = c6926.m10115("Host");
        if (strM10115 != null) {
            arrayList.add(new C7005(C7005.f20386, strM10115));
        }
        arrayList.add(new C7005(C7005.f20385, c6926.f20128.f20014));
        int size = c6905.size();
        for (int i = 0; i < size; i++) {
            String strM10068 = c6905.m10068(i);
            Locale locale = Locale.US;
            C6635.m9823((Object) locale, "Locale.US");
            if (strM10068 == null) {
                throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
            }
            String lowerCase = strM10068.toLowerCase(locale);
            C6635.m9823((Object) lowerCase, "(this as java.lang.String).toLowerCase(locale)");
            if (!f20492.contains(lowerCase) || (C6635.m9825((Object) lowerCase, (Object) "te") && C6635.m9825((Object) c6905.m10070(i), (Object) "trailers"))) {
                arrayList.add(new C7005(lowerCase, c6905.m10070(i)));
            }
        }
        this.f20495 = this.f20500.m10297(0, arrayList, z);
        if (this.f20497) {
            C7036 c7036 = this.f20495;
            if (c7036 == null) {
                C6635.m9822();
                throw null;
            }
            c7036.m10328(EnumC7003.CANCEL);
            throw new IOException("Canceled");
        }
        C7036 c70362 = this.f20495;
        if (c70362 == null) {
            C6635.m9822();
            throw null;
        }
        c70362.f20521.mo10460(this.f20499.f20337, TimeUnit.MILLISECONDS);
        C7036 c70363 = this.f20495;
        if (c70363 == null) {
            C6635.m9822();
            throw null;
        }
        c70363.f20522.mo10460(this.f20499.f20338, TimeUnit.MILLISECONDS);
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ؠ */
    public InterfaceC7129 mo10255(C6933 c6933) {
        if (c6933 == null) {
            C6635.m9824("response");
            throw null;
        }
        C7036 c7036 = this.f20495;
        if (c7036 != null) {
            return c7036.f20519;
        }
        C6635.m9822();
        throw null;
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ؠ */
    public void mo10256() {
        this.f20500.f20443.flush();
    }

    @Override // p447.p448.p453.InterfaceC6984
    /* JADX INFO: renamed from: ހ */
    public C6968 mo10257() {
        return this.f20498;
    }
}
