package m4;

import java.io.InputStream;
import java.util.logging.Logger;
import k4.AbstractC2396i;
import u4.C2965a;

/* JADX INFO: renamed from: m4.p, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C2533p extends D {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ int f21125c = 0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ C4.f f21126d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ Object f21127e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2533p(C4.f fVar, k4.g0 g0Var) {
        super(((C2544t) fVar.f743d).f21158f, 0);
        this.f21126d = fVar;
        this.f21127e = g0Var;
    }

    @Override // m4.D
    public final void b() {
        switch (this.f21125c) {
            case 0:
                C4.f fVar = this.f21126d;
                u4.b.c();
                try {
                    u4.c cVar = ((C2544t) fVar.f743d).f21154b;
                    u4.b.a();
                    u4.b.f24588a.getClass();
                    if (((k4.r0) fVar.f742c) == null) {
                        try {
                            ((AbstractC2396i) fVar.f741b).onHeaders((k4.g0) this.f21127e);
                        } catch (Throwable th) {
                            k4.r0 r0VarG = k4.r0.f19939f.f(th).g("Failed to read headers");
                            fVar.f742c = r0VarG;
                            ((C2544t) fVar.f743d).f21162j.g(r0VarG);
                        }
                        break;
                    }
                    u4.b.f24588a.getClass();
                    return;
                } catch (Throwable th2) {
                    try {
                        u4.b.f24588a.getClass();
                        break;
                    } catch (Throwable th3) {
                        th2.addSuppressed(th3);
                    }
                    throw th2;
                }
            default:
                u4.b.c();
                try {
                    u4.c cVar2 = ((C2544t) this.f21126d.f743d).f21154b;
                    u4.b.a();
                    C2965a c2965a = u4.b.f24588a;
                    c2965a.getClass();
                    c();
                    c2965a.getClass();
                    return;
                } catch (Throwable th4) {
                    try {
                        u4.b.f24588a.getClass();
                        break;
                    } catch (Throwable th5) {
                        th4.addSuppressed(th5);
                    }
                    throw th4;
                }
        }
    }

    public void c() {
        C4.f fVar = this.f21126d;
        k4.r0 r0Var = (k4.r0) fVar.f742c;
        C2544t c2544t = (C2544t) fVar.f743d;
        l2.c cVar = (l2.c) this.f21127e;
        if (r0Var != null) {
            Logger logger = AbstractC2504f0.f20995a;
            while (true) {
                InputStream inputStreamG = cVar.g();
                if (inputStreamG == null) {
                    return;
                } else {
                    AbstractC2504f0.b(inputStreamG);
                }
            }
        } else {
            while (true) {
                try {
                    InputStream inputStreamG2 = cVar.g();
                    if (inputStreamG2 == null) {
                        return;
                    }
                    try {
                        ((AbstractC2396i) fVar.f741b).onMessage(c2544t.f21153a.c(inputStreamG2));
                        inputStreamG2.close();
                    } catch (Throwable th) {
                        AbstractC2504f0.b(inputStreamG2);
                        throw th;
                    }
                } catch (Throwable th2) {
                    Logger logger2 = AbstractC2504f0.f20995a;
                    while (true) {
                        InputStream inputStreamG3 = cVar.g();
                        if (inputStreamG3 == null) {
                            k4.r0 r0VarG = k4.r0.f19939f.f(th2).g("Failed to read message.");
                            fVar.f742c = r0VarG;
                            c2544t.f21162j.g(r0VarG);
                            return;
                        }
                        AbstractC2504f0.b(inputStreamG3);
                    }
                }
            }
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2533p(C4.f fVar, l2.c cVar) {
        super(((C2544t) fVar.f743d).f21158f, 0);
        this.f21126d = fVar;
        this.f21127e = cVar;
    }
}
