- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
152 lines
4.8 KiB
Java
152 lines
4.8 KiB
Java
package okhttp3.internal.http;
|
|
|
|
import androidx.webkit.ProxyConfig;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.TreeSet;
|
|
import okhttp3.Cookie;
|
|
import okhttp3.CookieJar;
|
|
import okhttp3.Headers;
|
|
import okhttp3.HttpUrl;
|
|
import okhttp3.Request;
|
|
import okhttp3.Response;
|
|
import okhttp3.internal.Util;
|
|
import okio.ByteString;
|
|
import org.apache.http.client.methods.HttpHead;
|
|
import org.apache.http.message.BasicHeaderValueFormatter;
|
|
import org.apache.http.protocol.HTTP;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public abstract class HttpHeaders {
|
|
public static final ByteString QUOTED_STRING_DELIMITERS = ByteString.encodeUtf8(BasicHeaderValueFormatter.UNSAFE_CHARS);
|
|
public static final ByteString TOKEN_DELIMITERS = ByteString.encodeUtf8("\t ,=");
|
|
|
|
public static long contentLength(Response response) {
|
|
return contentLength(response.headers());
|
|
}
|
|
|
|
public static long contentLength(Headers headers) {
|
|
return stringToLong(headers.get(HTTP.CONTENT_LEN));
|
|
}
|
|
|
|
public static long stringToLong(String str) {
|
|
if (str == null) {
|
|
return -1L;
|
|
}
|
|
try {
|
|
return Long.parseLong(str);
|
|
} catch (NumberFormatException unused) {
|
|
return -1L;
|
|
}
|
|
}
|
|
|
|
public static boolean varyMatches(Response response, Headers headers, Request request) {
|
|
for (String str : varyFields(response)) {
|
|
if (!Objects.equals(headers.values(str), request.headers(str))) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static boolean hasVaryAll(Response response) {
|
|
return hasVaryAll(response.headers());
|
|
}
|
|
|
|
public static boolean hasVaryAll(Headers headers) {
|
|
return varyFields(headers).contains(ProxyConfig.MATCH_ALL_SCHEMES);
|
|
}
|
|
|
|
public static Set varyFields(Response response) {
|
|
return varyFields(response.headers());
|
|
}
|
|
|
|
public static Set varyFields(Headers headers) {
|
|
Set emptySet = Collections.emptySet();
|
|
int size = headers.size();
|
|
for (int i = 0; i < size; i++) {
|
|
if ("Vary".equalsIgnoreCase(headers.name(i))) {
|
|
String value = headers.value(i);
|
|
if (emptySet.isEmpty()) {
|
|
emptySet = new TreeSet(String.CASE_INSENSITIVE_ORDER);
|
|
}
|
|
for (String str : value.split(",")) {
|
|
emptySet.add(str.trim());
|
|
}
|
|
}
|
|
}
|
|
return emptySet;
|
|
}
|
|
|
|
public static Headers varyHeaders(Response response) {
|
|
return varyHeaders(response.networkResponse().request().headers(), response.headers());
|
|
}
|
|
|
|
public static Headers varyHeaders(Headers headers, Headers headers2) {
|
|
Set varyFields = varyFields(headers2);
|
|
if (varyFields.isEmpty()) {
|
|
return Util.EMPTY_HEADERS;
|
|
}
|
|
Headers.Builder builder = new Headers.Builder();
|
|
int size = headers.size();
|
|
for (int i = 0; i < size; i++) {
|
|
String name = headers.name(i);
|
|
if (varyFields.contains(name)) {
|
|
builder.add(name, headers.value(i));
|
|
}
|
|
}
|
|
return builder.build();
|
|
}
|
|
|
|
public static void receiveHeaders(CookieJar cookieJar, HttpUrl httpUrl, Headers headers) {
|
|
if (cookieJar == CookieJar.NO_COOKIES) {
|
|
return;
|
|
}
|
|
List parseAll = Cookie.parseAll(httpUrl, headers);
|
|
if (parseAll.isEmpty()) {
|
|
return;
|
|
}
|
|
cookieJar.saveFromResponse(httpUrl, parseAll);
|
|
}
|
|
|
|
public static boolean hasBody(Response response) {
|
|
if (response.request().method().equals(HttpHead.METHOD_NAME)) {
|
|
return false;
|
|
}
|
|
int code = response.code();
|
|
return (((code >= 100 && code < 200) || code == 204 || code == 304) && contentLength(response) == -1 && !HTTP.CHUNK_CODING.equalsIgnoreCase(response.header(HTTP.TRANSFER_ENCODING))) ? false : true;
|
|
}
|
|
|
|
public static int skipUntil(String str, int i, String str2) {
|
|
while (i < str.length() && str2.indexOf(str.charAt(i)) == -1) {
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int skipWhitespace(String str, int i) {
|
|
char charAt;
|
|
while (i < str.length() && ((charAt = str.charAt(i)) == ' ' || charAt == '\t')) {
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int parseSeconds(String str, int i) {
|
|
try {
|
|
long parseLong = Long.parseLong(str);
|
|
if (parseLong > 2147483647L) {
|
|
return Integer.MAX_VALUE;
|
|
}
|
|
if (parseLong < 0) {
|
|
return 0;
|
|
}
|
|
return (int) parseLong;
|
|
} catch (NumberFormatException unused) {
|
|
return i;
|
|
}
|
|
}
|
|
}
|