package XnFJ5_9.Ft6VRog_36.Xgtqvk_8;

import XnFJ5_9.XuVgy_28;
import com.wang.avi.BuildConfig;
import java.io.IOException;
import java.net.ProtocolException;
/* compiled from: StatusLine.java */
/* loaded from: classes.dex */
public final class Nm6q_10 {
    public final int KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final XuVgy_28 f1627KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final String f1628KQgRr5e_0;

    public Nm6q_10(XuVgy_28 xuVgy_28, int i, String str) {
        this.f1627KQgRr5e_0 = xuVgy_28;
        this.KQgRr5e_0 = i;
        this.f1628KQgRr5e_0 = str;
    }

    public static Nm6q_10 KQgRr5e_0(String str) throws IOException {
        XuVgy_28 xuVgy_28;
        String str2;
        int i = 9;
        if (str.startsWith("HTTP/1.")) {
            if (str.length() >= 9 && str.charAt(8) == ' ') {
                int charAt = str.charAt(7) - '0';
                if (charAt == 0) {
                    xuVgy_28 = XuVgy_28.HTTP_1_0;
                } else if (charAt == 1) {
                    xuVgy_28 = XuVgy_28.HTTP_1_1;
                } else {
                    throw new ProtocolException("Unexpected status line: " + str);
                }
            } else {
                throw new ProtocolException("Unexpected status line: " + str);
            }
        } else if (str.startsWith("ICY ")) {
            xuVgy_28 = XuVgy_28.HTTP_1_0;
            i = 4;
        } else {
            throw new ProtocolException("Unexpected status line: " + str);
        }
        int i2 = i + 3;
        if (str.length() >= i2) {
            try {
                int parseInt = Integer.parseInt(str.substring(i, i2));
                if (str.length() <= i2) {
                    str2 = BuildConfig.FLAVOR;
                } else if (str.charAt(i2) == ' ') {
                    str2 = str.substring(i + 4);
                } else {
                    throw new ProtocolException("Unexpected status line: " + str);
                }
                return new Nm6q_10(xuVgy_28, parseInt, str2);
            } catch (NumberFormatException unused) {
                throw new ProtocolException("Unexpected status line: " + str);
            }
        }
        throw new ProtocolException("Unexpected status line: " + str);
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.f1627KQgRr5e_0 == XuVgy_28.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1");
        sb.append(' ');
        sb.append(this.KQgRr5e_0);
        if (this.f1628KQgRr5e_0 != null) {
            sb.append(' ');
            sb.append(this.f1628KQgRr5e_0);
        }
        return sb.toString();
    }
}
