package 㿎.ሽ.㸾;

import com.facebook.GraphRequest;
import com.facebook.appevents.AppEventsConstants;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import okhttp3.Protocol;
import 㿎.AbstractC2661;
import 㿎.C2644;
import 㿎.C2667;
import 㿎.C2671;
import 㿎.ሽ.AbstractC2570;
import 㿎.ሽ.C2540;
import 㿎.ሽ.㴹.C2583;

/* renamed from: 㿎.ሽ.㸾.K  reason: contains not printable characters */
/* compiled from: CacheInterceptor */
public final class C2589 implements AbstractC2661 {
    /* renamed from: ῲ  reason: contains not printable characters */
    public static boolean m6797(String str) {
        return !"Connection".equalsIgnoreCase(str) && !"Keep-Alive".equalsIgnoreCase(str) && !"Proxy-Authenticate".equalsIgnoreCase(str) && !"Proxy-Authorization".equalsIgnoreCase(str) && !"TE".equalsIgnoreCase(str) && !"Trailers".equalsIgnoreCase(str) && !"Transfer-Encoding".equalsIgnoreCase(str) && !"Upgrade".equalsIgnoreCase(str);
    }

    @Override // 㿎.AbstractC2661
    /* renamed from: K  reason: contains not printable characters */
    public C2671 m6800(AbstractC2661.AbstractC2662 k) throws IOException {
        System.currentTimeMillis();
        C2583 r14 = (C2583) k;
        C2644 r0 = r14.f8698;
        C2588 r1 = new C2588(r0, null);
        if (r1.f8710 != null && r0.m6963().f9051) {
            r1 = new C2588(null, null);
        }
        C2644 r02 = r1.f8710;
        C2671 r12 = r1.f8709;
        if (r02 == null && r12 == null) {
            C2671.C2672 k2 = new C2671.C2672();
            k2.f9101 = r14.f8698;
            k2.f9099 = Protocol.HTTP_1_1;
            k2.f9095 = 504;
            k2.f9105 = "Unsatisfiable Request (only-if-cached)";
            k2.f9100 = C2540.f8560;
            k2.f9097 = -1;
            k2.f9102 = System.currentTimeMillis();
            return k2.m7010();
        } else if (r02 == null) {
            C2671.C2672 r142 = r12.m7007();
            r142.m7009(m6798(r12));
            return r142.m7010();
        } else {
            C2671 r143 = r14.m6790(r02, r14.f8693, r14.f8689, r14.f8699);
            if (r12 != null) {
                if (r143.f9092 == 304) {
                    C2671.C2672 k3 = new C2671.C2672(r12);
                    C2667 r4 = r12.f9088;
                    C2667 r5 = r143.f9088;
                    C2667.C2668 k4 = new C2667.C2668();
                    int r7 = r4.m6993();
                    for (int i = 0; i < r7; i++) {
                        String r10 = r4.m6995(i);
                        String r11 = r4.m6994(i);
                        if ((!"Warning".equalsIgnoreCase(r10) || !r11.startsWith(AppEventsConstants.EVENT_PARAM_VALUE_YES)) && (m6799(r10) || !m6797(r10) || r5.m6996(r10) == null)) {
                            AbstractC2570.f8676.m6763(k4, r10, r11);
                        }
                    }
                    int r42 = r5.m6993();
                    for (int i2 = 0; i2 < r42; i2++) {
                        String r72 = r5.m6995(i2);
                        if (!m6799(r72) && m6797(r72)) {
                            AbstractC2570.f8676.m6763(k4, r72, r5.m6994(i2));
                        }
                    }
                    List<String> list = k4.f9081;
                    C2667.C2668 k5 = new C2667.C2668();
                    Collections.addAll(k5.f9081, (String[]) list.toArray(new String[list.size()]));
                    k3.f9104 = k5;
                    k3.f9097 = r143.f9089;
                    k3.f9102 = r143.f9094;
                    k3.m7009(m6798(r12));
                    C2671 r13 = m6798(r143);
                    if (r13 != null) {
                        k3.m7011("networkResponse", r13);
                    }
                    k3.f9106 = r13;
                    k3.m7010();
                    r143.f9093.close();
                    throw null;
                }
                C2540.m6651(r12.f9093);
            }
            C2671.C2672 r2 = r143.m7007();
            r2.m7009(m6798(r12));
            C2671 r144 = m6798(r143);
            if (r144 != null) {
                r2.m7011("networkResponse", r144);
            }
            r2.f9106 = r144;
            return r2.m7010();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static C2671 m6798(C2671 r1) {
        if (r1 == null || r1.f9093 == null) {
            return r1;
        }
        C2671.C2672 k = new C2671.C2672(r1);
        k.f9100 = null;
        return k.m7010();
    }

    /* renamed from: K  reason: contains not printable characters */
    public static boolean m6799(String str) {
        return "Content-Length".equalsIgnoreCase(str) || GraphRequest.CONTENT_ENCODING_HEADER.equalsIgnoreCase(str) || GraphRequest.CONTENT_TYPE_HEADER.equalsIgnoreCase(str);
    }
}
