Rabbit-R1/switch port/java/sources/okhttp3/internal/http/StatusLine.java

113 lines
6.2 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package okhttp3.internal.http;
import io.sentry.protocol.Response;
import java.io.IOException;
import java.net.ProtocolException;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import okhttp3.Protocol;
/* compiled from: StatusLine.kt */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001e\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\u0018\u0000 \n2\u00020\u0001:\u0001\nB\u001d\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJ\b\u0010\t\u001a\u00020\u0007H\u0016R\u0010\u0010\u0004\u001a\u00020\u00058\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u00020\u00078\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0002\u001a\u00020\u00038\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\u000b"}, d2 = {"Lokhttp3/internal/http/StatusLine;", "", "protocol", "Lokhttp3/Protocol;", "code", "", "message", "", "(Lokhttp3/Protocol;ILjava/lang/String;)V", "toString", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
/* loaded from: classes3.dex */
public final class StatusLine {
/* renamed from: Companion, reason: from kotlin metadata */
public static final Companion INSTANCE = new Companion(null);
public static final int HTTP_CONTINUE = 100;
public static final int HTTP_MISDIRECTED_REQUEST = 421;
public static final int HTTP_PERM_REDIRECT = 308;
public static final int HTTP_TEMP_REDIRECT = 307;
public final int code;
public final String message;
public final Protocol protocol;
public StatusLine(Protocol protocol, int i, String message) {
Intrinsics.checkNotNullParameter(protocol, "protocol");
Intrinsics.checkNotNullParameter(message, "message");
this.protocol = protocol;
this.code = i;
this.message = message;
}
public String toString() {
StringBuilder sb = new StringBuilder();
if (this.protocol == Protocol.HTTP_1_0) {
sb.append("HTTP/1.0");
} else {
sb.append("HTTP/1.1");
}
sb.append(' ').append(this.code);
sb.append(' ').append(this.message);
String sb2 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb2, "StringBuilder().apply(builderAction).toString()");
return sb2;
}
/* compiled from: StatusLine.kt */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\u000bJ\u000e\u0010\f\u001a\u00020\t2\u0006\u0010\r\u001a\u00020\u000eR\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000¨\u0006\u000f"}, d2 = {"Lokhttp3/internal/http/StatusLine$Companion;", "", "()V", "HTTP_CONTINUE", "", "HTTP_MISDIRECTED_REQUEST", "HTTP_PERM_REDIRECT", "HTTP_TEMP_REDIRECT", "get", "Lokhttp3/internal/http/StatusLine;", Response.TYPE, "Lokhttp3/Response;", "parse", "statusLine", "", "okhttp"}, k = 1, mv = {1, 4, 0})
/* loaded from: classes3.dex */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final StatusLine get(okhttp3.Response response) {
Intrinsics.checkNotNullParameter(response, "response");
return new StatusLine(response.protocol(), response.code(), response.message());
}
public final StatusLine parse(String statusLine) throws IOException {
Protocol protocol;
int i;
String str;
Intrinsics.checkNotNullParameter(statusLine, "statusLine");
if (StringsKt.startsWith$default(statusLine, "HTTP/1.", false, 2, (Object) null)) {
i = 9;
if (statusLine.length() < 9 || statusLine.charAt(8) != ' ') {
throw new ProtocolException("Unexpected status line: " + statusLine);
}
int charAt = statusLine.charAt(7) - '0';
if (charAt == 0) {
protocol = Protocol.HTTP_1_0;
} else if (charAt == 1) {
protocol = Protocol.HTTP_1_1;
} else {
throw new ProtocolException("Unexpected status line: " + statusLine);
}
} else if (StringsKt.startsWith$default(statusLine, "ICY ", false, 2, (Object) null)) {
protocol = Protocol.HTTP_1_0;
i = 4;
} else {
throw new ProtocolException("Unexpected status line: " + statusLine);
}
int i2 = i + 3;
if (statusLine.length() < i2) {
throw new ProtocolException("Unexpected status line: " + statusLine);
}
try {
String substring = statusLine.substring(i, i2);
Intrinsics.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
int parseInt = Integer.parseInt(substring);
if (statusLine.length() <= i2) {
str = "";
} else {
if (statusLine.charAt(i2) != ' ') {
throw new ProtocolException("Unexpected status line: " + statusLine);
}
str = statusLine.substring(i + 4);
Intrinsics.checkNotNullExpressionValue(str, "(this as java.lang.String).substring(startIndex)");
}
return new StatusLine(protocol, parseInt, str);
} catch (NumberFormatException unused) {
throw new ProtocolException("Unexpected status line: " + statusLine);
}
}
}
}