package 㿎.ሽ.㴹;

import java.io.IOException;
import java.net.ProtocolException;
import ඓ.ⁱ.K.ඓ.C1252;
import ᨨ.AbstractC1473;
import ᨨ.AbstractC1481;
import ᨨ.AbstractC1483;
import ᨨ.C1486;
import ᨨ.C1492;
import 㿎.AbstractC2533;
import 㿎.AbstractC2537;
import 㿎.AbstractC2661;
import 㿎.C2644;
import 㿎.C2671;
import 㿎.ሽ.C2540;
import 㿎.ሽ.ඓ.C2543;
import 㿎.ሽ.ඓ.C2548;

/* renamed from: 㿎.ሽ.㴹.ῲ  reason: contains not printable characters */
/* compiled from: CallServerInterceptor */
public final class C2579 implements AbstractC2661 {

    /* renamed from: K  reason: contains not printable characters */
    public final boolean f8683;

    /* renamed from: 㿎.ሽ.㴹.ῲ$K  reason: contains not printable characters */
    /* compiled from: CallServerInterceptor */
    public static final class C2580 extends AbstractC1481 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public long f8684;

        public C2580(AbstractC1473 r1) {
            super(r1);
        }

        @Override // ᨨ.AbstractC1481, ᨨ.AbstractC1473
        /* renamed from: K  reason: contains not printable characters */
        public void m6787(C1492 r3, long j) throws IOException {
            super.m3725(r3, j);
            this.f8684 += j;
        }
    }

    public C2579(boolean z) {
        this.f8683 = z;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:32:0x011b, code lost:
        if ("close".equalsIgnoreCase(r0) != false) goto L_0x011d;
     */
    @Override // 㿎.AbstractC2661
    /* renamed from: K  reason: contains not printable characters */
    public C2671 m6786(AbstractC2661.AbstractC2662 k) throws IOException {
        C2671.C2672 k2;
        C2671 r12;
        C2583 r122 = (C2583) k;
        AbstractC2576 r0 = r122.f8689;
        C2548 r1 = r122.f8693;
        C2543 r2 = r122.f8699;
        C2644 r3 = r122.f8698;
        long currentTimeMillis = System.currentTimeMillis();
        AbstractC2533 r6 = r122.f8700;
        AbstractC2537 r7 = r122.f8694;
        r6.m6609();
        r0.m6779(r3);
        AbstractC2533 r62 = r122.f8700;
        AbstractC2537 r72 = r122.f8694;
        r62.m6626();
        if (!C1252.m3330(r3.f8984) || r3.f8987 == null) {
            k2 = null;
        } else {
            if ("100-continue".equalsIgnoreCase(r3.f8982.m6996("Expect"))) {
                r0.m6774();
                AbstractC2533 r63 = r122.f8700;
                AbstractC2537 r8 = r122.f8694;
                r63.m6621();
                k2 = r0.m6777(true);
            } else {
                k2 = null;
            }
            if (k2 == null) {
                AbstractC2533 r22 = r122.f8700;
                AbstractC2537 r82 = r122.f8694;
                r22.m6619();
                C2580 k3 = new C2580(r0.m6775(r3, r3.f8987.contentLength()));
                AbstractC1483 r83 = C1486.m3737(k3);
                r3.f8987.writeTo(r83);
                r83.close();
                AbstractC2533 r84 = r122.f8700;
                AbstractC2537 r9 = r122.f8694;
                long j = k3.f8684;
                r84.m6614();
            } else if (!r2.m6666()) {
                r1.m6687();
            }
        }
        r0.m6778();
        if (k2 == null) {
            AbstractC2533 r64 = r122.f8700;
            AbstractC2537 r85 = r122.f8694;
            r64.m6621();
            k2 = r0.m6777(false);
        }
        k2.f9101 = r3;
        k2.f9096 = r1.m6676().f8589;
        k2.f9097 = currentTimeMillis;
        k2.f9102 = System.currentTimeMillis();
        C2671 r65 = k2.m7010();
        int i = r65.f9092;
        if (i == 100) {
            C2671.C2672 r23 = r0.m6777(false);
            r23.f9101 = r3;
            r23.f9096 = r1.m6676().f8589;
            r23.f9097 = currentTimeMillis;
            r23.f9102 = System.currentTimeMillis();
            r65 = r23.m7010();
            i = r65.f9092;
        }
        AbstractC2533 r24 = r122.f8700;
        AbstractC2537 r123 = r122.f8694;
        r24.m6613();
        if (!this.f8683 || i != 101) {
            C2671.C2672 k4 = new C2671.C2672(r65);
            k4.f9100 = r0.m6776(r65);
            r12 = k4.m7010();
        } else {
            C2671.C2672 k5 = new C2671.C2672(r65);
            k5.f9100 = C2540.f8560;
            r12 = k5.m7010();
        }
        if (!"close".equalsIgnoreCase(r12.f9087.f8982.m6996("Connection"))) {
            String r02 = r12.f9088.m6996("Connection");
            if (r02 == null) {
                r02 = null;
            }
        }
        r1.m6687();
        if ((i != 204 && i != 205) || r12.f9093.contentLength() <= 0) {
            return r12;
        }
        throw new ProtocolException("HTTP " + i + " had non-zero Content-Length: " + r12.f9093.contentLength());
    }
}
