package defpackage;

import android.os.Handler;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

/* JADX INFO: renamed from: ᵥᵕ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3505 implements InterfaceC1933 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final DataInputStream f13464;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public volatile boolean f13465;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C5019 f13466 = new C5019(3);

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final /* synthetic */ C5094 f13467;

    public C3505(C5094 c5094, InputStream inputStream) {
        this.f13467 = c5094;
        this.f13464 = new DataInputStream(inputStream);
    }

    @Override // defpackage.InterfaceC1933
    /* JADX INFO: renamed from: ᵱᵽʡᵚ */
    public final void mo3273() {
        this.f13465 = true;
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x00a3  */
    @Override // defpackage.InterfaceC1933
    /* JADX INFO: renamed from: ᵵᵽ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void mo3275() throws IOException {
        while (!this.f13465) {
            byte b = this.f13464.readByte();
            if (b == 36) {
                int unsignedByte = this.f13464.readUnsignedByte();
                int unsignedShort = this.f13464.readUnsignedShort();
                byte[] bArr = new byte[unsignedShort];
                this.f13464.readFully(bArr, 0, unsignedShort);
                C2883 c2883 = (C2883) this.f13467.f19193.get(Integer.valueOf(unsignedByte));
                if (c2883 != null && !this.f13467.f19197) {
                    c2883.f11008.add(bArr);
                }
            } else if (this.f13467.f19197) {
                continue;
            } else {
                C1709 c1709 = this.f13467.f19192;
                C5019 c5019 = this.f13466;
                DataInputStream dataInputStream = this.f13464;
                c5019.getClass();
                AbstractC4509 abstractC4509M10356 = c5019.m10356(C5019.m10352(b, dataInputStream));
                while (abstractC4509M10356 == null) {
                    if (c5019.f19020 == 3) {
                        long j = c5019.f19018;
                        if (j <= 0) {
                            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Expects a greater than zero Content-Length.");
                            return;
                        }
                        int i = ᵝˉː.ᵷᵺʾᵖ(j);
                        ᵻᵪ.ˌᴵ(i != -1);
                        byte[] bArr2 = new byte[i];
                        dataInputStream.readFully(bArr2, 0, i);
                        ArrayList arrayList = (ArrayList) c5019.f19019;
                        ᵻᵪ.ˌᴵ(c5019.f19020 == 3);
                        if (i > 0) {
                            int i2 = i - 1;
                            if (bArr2[i2] == 10) {
                                if (i > 1) {
                                    int i3 = i - 2;
                                    String str = bArr2[i3] == 13 ? new String(bArr2, 0, i3, C5094.f19191) : new String(bArr2, 0, i2, C5094.f19191);
                                    arrayList.add(str);
                                    abstractC4509M10356 = AbstractC4509.m9559(arrayList);
                                    ((ArrayList) c5019.f19019).clear();
                                    c5019.f19020 = 1;
                                    c5019.f19018 = 0L;
                                }
                            }
                        }
                        ᵕᵩʽᵲ.ᵮᵣᵗˈ("Message body is empty or does not end with a LF.");
                        return;
                    }
                    abstractC4509M10356 = c5019.m10356(C5019.m10352(dataInputStream.readByte(), dataInputStream));
                }
                ((Handler) c1709.f6833).post(new RunnableC2093(c1709, 15, abstractC4509M10356));
            }
        }
    }
}
