107 lines
3.7 KiB
Java
107 lines
3.7 KiB
Java
package okhttp3.internal.http;
|
|
|
|
import java.io.IOException;
|
|
import java.net.ProtocolException;
|
|
import o.C14953gcr;
|
|
import o.C14957gcv;
|
|
import o.gdZ;
|
|
import okhttp3.Protocol;
|
|
import okhttp3.Response;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class StatusLine {
|
|
public static final Companion Companion = 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 str) {
|
|
C14957gcv.e(protocol, "");
|
|
C14957gcv.e(str, "");
|
|
this.protocol = protocol;
|
|
this.code = i;
|
|
this.message = str;
|
|
}
|
|
|
|
public final 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(' ');
|
|
sb.append(this.code);
|
|
sb.append(' ');
|
|
sb.append(this.message);
|
|
String obj = sb.toString();
|
|
C14957gcv.c((Object) obj, "");
|
|
return obj;
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public final StatusLine get(Response response) {
|
|
C14957gcv.e(response, "");
|
|
return new StatusLine(response.protocol(), response.code(), response.message());
|
|
}
|
|
|
|
public final StatusLine parse(String str) throws IOException {
|
|
Protocol protocol;
|
|
int i;
|
|
String str2 = "";
|
|
C14957gcv.e(str, "");
|
|
if (gdZ.e(str, "HTTP/1.", false)) {
|
|
i = 9;
|
|
if (str.length() < 9 || str.charAt(8) != ' ') {
|
|
throw new ProtocolException(C14957gcv.c("Unexpected status line: ", (Object) 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(C14957gcv.c("Unexpected status line: ", (Object) str));
|
|
}
|
|
} else if (gdZ.e(str, "ICY ", false)) {
|
|
protocol = Protocol.HTTP_1_0;
|
|
i = 4;
|
|
} else {
|
|
throw new ProtocolException(C14957gcv.c("Unexpected status line: ", (Object) str));
|
|
}
|
|
int i2 = i + 3;
|
|
if (str.length() < i2) {
|
|
throw new ProtocolException(C14957gcv.c("Unexpected status line: ", (Object) str));
|
|
}
|
|
try {
|
|
String substring = str.substring(i, i2);
|
|
C14957gcv.c((Object) substring, "");
|
|
int parseInt = Integer.parseInt(substring);
|
|
if (str.length() > i2) {
|
|
if (str.charAt(i2) != ' ') {
|
|
throw new ProtocolException(C14957gcv.c("Unexpected status line: ", (Object) str));
|
|
}
|
|
String substring2 = str.substring(i + 4);
|
|
C14957gcv.c((Object) substring2, "");
|
|
str2 = substring2;
|
|
}
|
|
return new StatusLine(protocol, parseInt, str2);
|
|
} catch (NumberFormatException unused) {
|
|
throw new ProtocolException(C14957gcv.c("Unexpected status line: ", (Object) str));
|
|
}
|
|
}
|
|
|
|
public /* synthetic */ Companion(C14953gcr c14953gcr) {
|
|
this();
|
|
}
|
|
}
|
|
}
|