package p447.p448.p453;

import java.util.List;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.p411.p413.C6635;
import p402.p420.C6703;
import p447.AbstractC6930;
import p447.AbstractC6936;
import p447.C6884;
import p447.C6905;
import p447.C6914;
import p447.C6926;
import p447.C6933;
import p447.InterfaceC6886;
import p447.InterfaceC6912;
import p447.p448.C6943;
import p461.C7113;
import p461.InterfaceC7129;

/* JADX INFO: renamed from: ސ.ޣ.ޅ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C6980 implements InterfaceC6912 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC6886 f20323;

    public C6980(InterfaceC6886 interfaceC6886) {
        if (interfaceC6886 != null) {
            this.f20323 = interfaceC6886;
        } else {
            C6635.m9824("cookieJar");
            throw null;
        }
    }

    @Override // p447.InterfaceC6912
    public C6933 intercept(InterfaceC6912.InterfaceC6913 interfaceC6913) {
        boolean z;
        AbstractC6936 abstractC6936;
        if (interfaceC6913 == null) {
            C6635.m9824("chain");
            throw null;
        }
        C6926 c6926Mo10102 = interfaceC6913.mo10102();
        if (c6926Mo10102 == null) {
            throw null;
        }
        C6926.C6927 c6927 = new C6926.C6927(c6926Mo10102);
        AbstractC6930 abstractC6930 = c6926Mo10102.f20131;
        if (abstractC6930 != null) {
            C6914 c6914ContentType = abstractC6930.contentType();
            if (c6914ContentType != null) {
                c6927.m10119("Content-Type", c6914ContentType.f20035);
            }
            long jContentLength = abstractC6930.contentLength();
            if (jContentLength != -1) {
                c6927.m10119("Content-Length", String.valueOf(jContentLength));
                c6927.m10118("Transfer-Encoding");
            } else {
                c6927.m10119("Transfer-Encoding", "chunked");
                c6927.m10118("Content-Length");
            }
        }
        int i = 0;
        if (c6926Mo10102.m10115("Host") == null) {
            c6927.m10119("Host", C6943.m10157(c6926Mo10102.f20128, false));
        }
        if (c6926Mo10102.m10115("Connection") == null) {
            c6927.m10119("Connection", "Keep-Alive");
        }
        if (c6926Mo10102.m10115("Accept-Encoding") == null && c6926Mo10102.m10115("Range") == null) {
            c6927.m10119("Accept-Encoding", "gzip");
            z = true;
        } else {
            z = false;
        }
        List<C6884> listMo10047 = this.f20323.mo10047(c6926Mo10102.f20128);
        if (!listMo10047.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            for (Object obj : listMo10047) {
                int i2 = i + 1;
                if (i < 0) {
                    C4303.m7193();
                    throw null;
                }
                C6884 c6884 = (C6884) obj;
                if (i > 0) {
                    sb.append("; ");
                }
                sb.append(c6884.f19977);
                sb.append('=');
                sb.append(c6884.f19978);
                i = i2;
            }
            String string = sb.toString();
            C6635.m9823((Object) string, "StringBuilder().apply(builderAction).toString()");
            c6927.m10119("Cookie", string);
        }
        if (c6926Mo10102.m10115("User-Agent") == null) {
            c6927.m10119("User-Agent", "okhttp/4.7.2");
        }
        C6933 c6933Mo10101 = interfaceC6913.mo10101(c6927.m10123());
        C6985.m10260(this.f20323, c6926Mo10102.f20128, c6933Mo10101.f20151);
        C6933.C6934 c6934 = new C6933.C6934(c6933Mo10101);
        c6934.f20159 = c6926Mo10102;
        if (z && C6703.m9905("gzip", C6933.m10126(c6933Mo10101, "Content-Encoding", null, 2), true) && C6985.m10262(c6933Mo10101) && (abstractC6936 = c6933Mo10101.f20152) != null) {
            C7113 c7113 = new C7113(abstractC6936.mo10137());
            C6905.C6906 c6906M10069 = c6933Mo10101.f20151.m10069();
            c6906M10069.m10071("Content-Encoding");
            c6906M10069.m10071("Content-Length");
            c6934.m10129(c6906M10069.m10073());
            c6934.f20165 = new C6988(C6933.m10126(c6933Mo10101, "Content-Type", null, 2), -1L, C4303.m7076((InterfaceC7129) c7113));
        }
        return c6934.m10133();
    }
}
