package 㿎.ሽ.㴹;

import java.io.IOException;
import java.net.ProtocolException;
import okhttp3.Protocol;
import ඓ.K.K.K.C1293;

/* renamed from: 㿎.ሽ.㴹.ᨨ  reason: contains not printable characters */
/* compiled from: StatusLine */
public final class C2578 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final String f8680;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final int f8681;

    /* renamed from: K  reason: contains not printable characters */
    public final Protocol f8682;

    public C2578(Protocol protocol, int i, String str) {
        this.f8682 = protocol;
        this.f8681 = i;
        this.f8680 = str;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static C2578 m6785(String str) throws IOException {
        Protocol protocol;
        String str2;
        int i = 9;
        if (str.startsWith("HTTP/1.")) {
            if (str.length() < 9 || str.charAt(8) != ' ') {
                throw new ProtocolException(C1293.m3412("Unexpected status line: ", str));
            }
            int charAt = str.charAt(7) - '0';
            if (charAt == 0) {
                protocol = Protocol.HTTP_1_0;
            } else if (charAt == 1) {
                protocol = Protocol.HTTP_1_1;
            } else {
                throw new ProtocolException(C1293.m3412("Unexpected status line: ", str));
            }
        } else if (str.startsWith("ICY ")) {
            protocol = Protocol.HTTP_1_0;
            i = 4;
        } else {
            throw new ProtocolException(C1293.m3412("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 = "";
                } else if (str.charAt(i2) == ' ') {
                    str2 = str.substring(i + 4);
                } else {
                    throw new ProtocolException(C1293.m3412("Unexpected status line: ", str));
                }
                return new C2578(protocol, parseInt, str2);
            } catch (NumberFormatException unused) {
                throw new ProtocolException(C1293.m3412("Unexpected status line: ", str));
            }
        } else {
            throw new ProtocolException(C1293.m3412("Unexpected status line: ", str));
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.f8682 == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1");
        sb.append(' ');
        sb.append(this.f8681);
        if (this.f8680 != null) {
            sb.append(' ');
            sb.append(this.f8680);
        }
        return sb.toString();
    }
}
