Rabbit-R1/original r1/java/sources/okhttp3/internal/Util.java

861 lines
45 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package okhttp3.internal;
import androidx.exifinterface.media.ExifInterface;
import com.google.common.net.HttpHeaders;
import io.flutter.plugin.editing.SpellCheckPlugin;
import io.sentry.ProfilingTraceData;
import io.sentry.protocol.MetricSummary;
import io.sentry.protocol.SentryThread;
import io.sentry.protocol.TransactionInfo;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import kotlin.ExceptionsKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.collections.IntIterator;
import kotlin.collections.MapsKt;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.InlineMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.jvm.internal.TypeIntrinsics;
import kotlin.ranges.IntRange;
import kotlin.ranges.RangesKt;
import kotlin.text.Charsets;
import kotlin.text.Regex;
import kotlin.text.StringsKt;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.http2.Header;
import okhttp3.internal.io.FileSystem;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.ByteString;
import okio.Options;
import okio.Sink;
import okio.Source;
/* compiled from: Util.kt */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000¸\u0002\n\u0000\n\u0002\u0010\u0012\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0010\u0011\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010!\n\u0002\b\u0003\n\u0002\u0010\u0005\n\u0000\n\u0002\u0010\n\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\f\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u001c\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010$\n\u0002\b\b\n\u0002\u0010\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a \u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00112\u0006\u0010\u0016\u001a\u00020\u00172\b\u0010\u0018\u001a\u0004\u0018\u00010\u0019\u001a\u001e\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u00172\u0006\u0010\u001d\u001a\u00020\u00172\u0006\u0010\u001e\u001a\u00020\u0017\u001a'\u0010\u001f\u001a\u00020\u00112\u0006\u0010\u001f\u001a\u00020\u00112\u0012\u0010 \u001a\n\u0012\u0006\b\u0001\u0012\u00020\"0!\"\u00020\"¢\u0006\u0002\u0010#\u001a\u001a\u0010$\u001a\u00020\u001b2\f\u0010%\u001a\b\u0012\u0004\u0012\u00020\u001b0&H\u0086\\u0001\u0000\u001a-\u0010'\u001a\b\u0012\u0004\u0012\u0002H)0(\"\u0004\b\u0000\u0010)2\u0012\u0010*\u001a\n\u0012\u0006\b\u0001\u0012\u0002H)0!\"\u0002H)H\u0007¢\u0006\u0002\u0010+\u001a1\u0010,\u001a\u0004\u0018\u0001H)\"\u0004\b\u0000\u0010)2\u0006\u0010-\u001a\u00020\"2\f\u0010.\u001a\b\u0012\u0004\u0012\u0002H)0/2\u0006\u00100\u001a\u00020\u0011¢\u0006\u0002\u00101\u001a\u0016\u00102\u001a\u0002032\u0006\u0010\u0015\u001a\u00020\u00112\u0006\u00104\u001a\u00020\u000f\u001a\"\u00105\u001a\u00020\u001b2\u0006\u0010\u0015\u001a\u00020\u00112\f\u0010%\u001a\b\u0012\u0004\u0012\u00020\u001b0&H\u0086\\u0001\u0000\u001a%\u00106\u001a\u00020\u001b\"\u0004\b\u0000\u00107*\b\u0012\u0004\u0012\u0002H7082\u0006\u00109\u001a\u0002H7H\u0000¢\u0006\u0002\u0010:\u001a\u0015\u0010;\u001a\u00020\u0014*\u00020<2\u0006\u0010=\u001a\u00020\u0014H\u0086\u0004\u001a\u0015\u0010;\u001a\u00020\u0017*\u00020\u00142\u0006\u0010=\u001a\u00020\u0017H\u0086\u0004\u001a\u0015\u0010;\u001a\u00020\u0014*\u00020>2\u0006\u0010=\u001a\u00020\u0014H\u0086\u0004\u001a\n\u0010?\u001a\u00020@*\u00020A\u001a\r\u0010B\u001a\u00020\u001b*\u00020\"H\u0080\b\u001a\r\u0010C\u001a\u00020\u001b*\u00020\"H\u0080\b\u001a\n\u0010D\u001a\u00020\u000f*\u00020\u0011\u001a\u0012\u0010E\u001a\u00020\u000f*\u00020F2\u0006\u0010G\u001a\u00020F\u001a\n\u0010H\u001a\u00020\u001b*\u00020I\u001a\n\u0010H\u001a\u00020\u001b*\u00020J\u001a\n\u0010H\u001a\u00020\u001b*\u00020K\u001a#\u0010L\u001a\b\u0012\u0004\u0012\u00020\u00110!*\b\u0012\u0004\u0012\u00020\u00110!2\u0006\u0010M\u001a\u00020\u0011¢\u0006\u0002\u0010N\u001a&\u0010O\u001a\u00020\u0014*\u00020\u00112\u0006\u0010P\u001a\u00020Q2\b\b\u0002\u0010R\u001a\u00020\u00142\b\b\u0002\u0010S\u001a\u00020\u0014\u001a&\u0010O\u001a\u00020\u0014*\u00020\u00112\u0006\u0010T\u001a\u00020\u00112\b\b\u0002\u0010R\u001a\u00020\u00142\b\b\u0002\u0010S\u001a\u00020\u0014\u001a\u001a\u0010U\u001a\u00020\u000f*\u00020V2\u0006\u0010W\u001a\u00020\u00142\u0006\u0010X\u001a\u00020\u0019\u001a;\u0010Y\u001a\b\u0012\u0004\u0012\u0002H)0(\"\u0004\b\u00
/* loaded from: classes3.dex */
public final class Util {
public static final byte[] EMPTY_BYTE_ARRAY;
public static final RequestBody EMPTY_REQUEST;
public static final ResponseBody EMPTY_RESPONSE;
public static final TimeZone UTC;
private static final Regex VERIFY_AS_IP_ADDRESS;
public static final boolean assertionsEnabled;
public static final String okHttpName;
public static final String userAgent = "okhttp/4.9.1";
public static final Headers EMPTY_HEADERS = Headers.INSTANCE.of(new String[0]);
private static final Options UNICODE_BOMS = Options.INSTANCE.of(ByteString.INSTANCE.decodeHex("efbbbf"), ByteString.INSTANCE.decodeHex("feff"), ByteString.INSTANCE.decodeHex("fffe"), ByteString.INSTANCE.decodeHex("0000ffff"), ByteString.INSTANCE.decodeHex("ffff0000"));
public static final int and(byte b, int i) {
return b & i;
}
public static final int and(short s, int i) {
return s & i;
}
public static final long and(int i, long j) {
return i & j;
}
public static final int parseHexDigit(char c) {
if ('0' <= c && '9' >= c) {
return c - '0';
}
if ('a' <= c && 'f' >= c) {
return c - 'W';
}
if ('A' <= c && 'F' >= c) {
return c - '7';
}
return -1;
}
static {
byte[] bArr = new byte[0];
EMPTY_BYTE_ARRAY = bArr;
EMPTY_RESPONSE = ResponseBody.Companion.create$default(ResponseBody.INSTANCE, bArr, (MediaType) null, 1, (Object) null);
EMPTY_REQUEST = RequestBody.Companion.create$default(RequestBody.INSTANCE, bArr, (MediaType) null, 0, 0, 7, (Object) null);
TimeZone timeZone = TimeZone.getTimeZone("GMT");
Intrinsics.checkNotNull(timeZone);
UTC = timeZone;
VERIFY_AS_IP_ADDRESS = new Regex("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");
assertionsEnabled = false;
String name = OkHttpClient.class.getName();
Intrinsics.checkNotNullExpressionValue(name, "OkHttpClient::class.java.name");
okHttpName = StringsKt.removeSuffix(StringsKt.removePrefix(name, (CharSequence) "okhttp3."), (CharSequence) "Client");
}
public static final void checkOffsetAndCount(long j, long j2, long j3) {
if ((j2 | j3) < 0 || j2 > j || j - j2 < j3) {
throw new ArrayIndexOutOfBoundsException();
}
}
public static final ThreadFactory threadFactory(final String name, final boolean z) {
Intrinsics.checkNotNullParameter(name, "name");
return new ThreadFactory() { // from class: okhttp3.internal.Util$threadFactory$1
@Override // java.util.concurrent.ThreadFactory
public final Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, name);
thread.setDaemon(z);
return thread;
}
};
}
public static final String[] intersect(String[] intersect, String[] other, Comparator<? super String> comparator) {
Intrinsics.checkNotNullParameter(intersect, "$this$intersect");
Intrinsics.checkNotNullParameter(other, "other");
Intrinsics.checkNotNullParameter(comparator, "comparator");
ArrayList arrayList = new ArrayList();
for (String str : intersect) {
int length = other.length;
int i = 0;
while (true) {
if (i >= length) {
break;
}
if (comparator.compare(str, other[i]) == 0) {
arrayList.add(str);
break;
}
i++;
}
}
Object[] array = arrayList.toArray(new String[0]);
if (array != null) {
return (String[]) array;
}
throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
}
public static final boolean hasIntersection(String[] hasIntersection, String[] strArr, Comparator<? super String> comparator) {
Intrinsics.checkNotNullParameter(hasIntersection, "$this$hasIntersection");
Intrinsics.checkNotNullParameter(comparator, "comparator");
if (hasIntersection.length != 0 && strArr != null && strArr.length != 0) {
for (String str : hasIntersection) {
for (String str2 : strArr) {
if (comparator.compare(str, str2) == 0) {
return true;
}
}
}
}
return false;
}
public static /* synthetic */ String toHostHeader$default(HttpUrl httpUrl, boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = false;
}
return toHostHeader(httpUrl, z);
}
public static final String toHostHeader(HttpUrl toHostHeader, boolean z) {
String host;
Intrinsics.checkNotNullParameter(toHostHeader, "$this$toHostHeader");
if (StringsKt.contains$default((CharSequence) toHostHeader.host(), (CharSequence) ":", false, 2, (Object) null)) {
host = "[" + toHostHeader.host() + ']';
} else {
host = toHostHeader.host();
}
return (z || toHostHeader.port() != HttpUrl.INSTANCE.defaultPort(toHostHeader.scheme())) ? host + ':' + toHostHeader.port() : host;
}
public static final String[] concat(String[] concat, String value) {
Intrinsics.checkNotNullParameter(concat, "$this$concat");
Intrinsics.checkNotNullParameter(value, "value");
Object[] copyOf = Arrays.copyOf(concat, concat.length + 1);
Intrinsics.checkNotNullExpressionValue(copyOf, "java.util.Arrays.copyOf(this, newSize)");
String[] strArr = (String[]) copyOf;
strArr[ArraysKt.getLastIndex(strArr)] = value;
if (strArr != null) {
return strArr;
}
throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<kotlin.String>");
}
public static /* synthetic */ int indexOfFirstNonAsciiWhitespace$default(String str, int i, int i2, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = 0;
}
if ((i3 & 2) != 0) {
i2 = str.length();
}
return indexOfFirstNonAsciiWhitespace(str, i, i2);
}
public static final int indexOfFirstNonAsciiWhitespace(String indexOfFirstNonAsciiWhitespace, int i, int i2) {
Intrinsics.checkNotNullParameter(indexOfFirstNonAsciiWhitespace, "$this$indexOfFirstNonAsciiWhitespace");
while (i < i2) {
char charAt = indexOfFirstNonAsciiWhitespace.charAt(i);
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
return i;
}
i++;
}
return i2;
}
public static /* synthetic */ int indexOfLastNonAsciiWhitespace$default(String str, int i, int i2, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = 0;
}
if ((i3 & 2) != 0) {
i2 = str.length();
}
return indexOfLastNonAsciiWhitespace(str, i, i2);
}
public static final int indexOfLastNonAsciiWhitespace(String indexOfLastNonAsciiWhitespace, int i, int i2) {
Intrinsics.checkNotNullParameter(indexOfLastNonAsciiWhitespace, "$this$indexOfLastNonAsciiWhitespace");
int i3 = i2 - 1;
if (i3 >= i) {
while (true) {
char charAt = indexOfLastNonAsciiWhitespace.charAt(i3);
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
return i3 + 1;
}
if (i3 == i) {
break;
}
i3--;
}
}
return i;
}
public static /* synthetic */ String trimSubstring$default(String str, int i, int i2, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = 0;
}
if ((i3 & 2) != 0) {
i2 = str.length();
}
return trimSubstring(str, i, i2);
}
public static final String trimSubstring(String trimSubstring, int i, int i2) {
Intrinsics.checkNotNullParameter(trimSubstring, "$this$trimSubstring");
int indexOfFirstNonAsciiWhitespace = indexOfFirstNonAsciiWhitespace(trimSubstring, i, i2);
String substring = trimSubstring.substring(indexOfFirstNonAsciiWhitespace, indexOfLastNonAsciiWhitespace(trimSubstring, indexOfFirstNonAsciiWhitespace, i2));
Intrinsics.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
return substring;
}
public static /* synthetic */ int delimiterOffset$default(String str, String str2, int i, int i2, int i3, Object obj) {
if ((i3 & 2) != 0) {
i = 0;
}
if ((i3 & 4) != 0) {
i2 = str.length();
}
return delimiterOffset(str, str2, i, i2);
}
public static final int delimiterOffset(String delimiterOffset, String delimiters, int i, int i2) {
Intrinsics.checkNotNullParameter(delimiterOffset, "$this$delimiterOffset");
Intrinsics.checkNotNullParameter(delimiters, "delimiters");
while (i < i2) {
if (StringsKt.contains$default((CharSequence) delimiters, delimiterOffset.charAt(i), false, 2, (Object) null)) {
return i;
}
i++;
}
return i2;
}
public static /* synthetic */ int delimiterOffset$default(String str, char c, int i, int i2, int i3, Object obj) {
if ((i3 & 2) != 0) {
i = 0;
}
if ((i3 & 4) != 0) {
i2 = str.length();
}
return delimiterOffset(str, c, i, i2);
}
public static final int delimiterOffset(String delimiterOffset, char c, int i, int i2) {
Intrinsics.checkNotNullParameter(delimiterOffset, "$this$delimiterOffset");
while (i < i2) {
if (delimiterOffset.charAt(i) == c) {
return i;
}
i++;
}
return i2;
}
public static final int indexOfControlOrNonAscii(String indexOfControlOrNonAscii) {
Intrinsics.checkNotNullParameter(indexOfControlOrNonAscii, "$this$indexOfControlOrNonAscii");
int length = indexOfControlOrNonAscii.length();
for (int i = 0; i < length; i++) {
char charAt = indexOfControlOrNonAscii.charAt(i);
if (Intrinsics.compare((int) charAt, 31) <= 0 || Intrinsics.compare((int) charAt, 127) >= 0) {
return i;
}
}
return -1;
}
public static final boolean canParseAsIpAddress(String canParseAsIpAddress) {
Intrinsics.checkNotNullParameter(canParseAsIpAddress, "$this$canParseAsIpAddress");
return VERIFY_AS_IP_ADDRESS.matches(canParseAsIpAddress);
}
public static final String format(String format, Object... args) {
Intrinsics.checkNotNullParameter(format, "format");
Intrinsics.checkNotNullParameter(args, "args");
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
Locale locale = Locale.US;
Object[] copyOf = Arrays.copyOf(args, args.length);
String format2 = String.format(locale, format, Arrays.copyOf(copyOf, copyOf.length));
Intrinsics.checkNotNullExpressionValue(format2, "java.lang.String.format(locale, format, *args)");
return format2;
}
public static final Charset readBomAsCharset(BufferedSource readBomAsCharset, Charset charset) throws IOException {
Intrinsics.checkNotNullParameter(readBomAsCharset, "$this$readBomAsCharset");
Intrinsics.checkNotNullParameter(charset, "default");
int select = readBomAsCharset.select(UNICODE_BOMS);
if (select == -1) {
return charset;
}
if (select == 0) {
Charset UTF_8 = StandardCharsets.UTF_8;
Intrinsics.checkNotNullExpressionValue(UTF_8, "UTF_8");
return UTF_8;
}
if (select == 1) {
Charset UTF_16BE = StandardCharsets.UTF_16BE;
Intrinsics.checkNotNullExpressionValue(UTF_16BE, "UTF_16BE");
return UTF_16BE;
}
if (select == 2) {
Charset UTF_16LE = StandardCharsets.UTF_16LE;
Intrinsics.checkNotNullExpressionValue(UTF_16LE, "UTF_16LE");
return UTF_16LE;
}
if (select == 3) {
return Charsets.INSTANCE.UTF32_BE();
}
if (select == 4) {
return Charsets.INSTANCE.UTF32_LE();
}
throw new AssertionError();
}
public static final int checkDuration(String name, long j, TimeUnit timeUnit) {
Intrinsics.checkNotNullParameter(name, "name");
boolean z = true;
if (!(j >= 0)) {
throw new IllegalStateException((name + " < 0").toString());
}
if (!(timeUnit != null)) {
throw new IllegalStateException("unit == null".toString());
}
long millis = timeUnit.toMillis(j);
if (!(millis <= ((long) Integer.MAX_VALUE))) {
throw new IllegalArgumentException((name + " too large.").toString());
}
if (millis == 0 && j > 0) {
z = false;
}
if (z) {
return (int) millis;
}
throw new IllegalArgumentException((name + " too small.").toString());
}
public static final Headers toHeaders(List<Header> toHeaders) {
Intrinsics.checkNotNullParameter(toHeaders, "$this$toHeaders");
Headers.Builder builder = new Headers.Builder();
for (Header header : toHeaders) {
builder.addLenient$okhttp(header.getName().utf8(), header.getValue().utf8());
}
return builder.build();
}
public static final List<Header> toHeaderList(Headers toHeaderList) {
Intrinsics.checkNotNullParameter(toHeaderList, "$this$toHeaderList");
IntRange until = RangesKt.until(0, toHeaderList.size());
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(until, 10));
Iterator<Integer> it = until.iterator();
while (it.hasNext()) {
int nextInt = ((IntIterator) it).nextInt();
arrayList.add(new Header(toHeaderList.name(nextInt), toHeaderList.value(nextInt)));
}
return arrayList;
}
public static final boolean canReuseConnectionFor(HttpUrl canReuseConnectionFor, HttpUrl other) {
Intrinsics.checkNotNullParameter(canReuseConnectionFor, "$this$canReuseConnectionFor");
Intrinsics.checkNotNullParameter(other, "other");
return Intrinsics.areEqual(canReuseConnectionFor.host(), other.host()) && canReuseConnectionFor.port() == other.port() && Intrinsics.areEqual(canReuseConnectionFor.scheme(), other.scheme());
}
public static final EventListener.Factory asFactory(final EventListener asFactory) {
Intrinsics.checkNotNullParameter(asFactory, "$this$asFactory");
return new EventListener.Factory() { // from class: okhttp3.internal.Util$asFactory$1
@Override // okhttp3.EventListener.Factory
public final EventListener create(Call it) {
Intrinsics.checkNotNullParameter(it, "it");
return EventListener.this;
}
};
}
public static final void writeMedium(BufferedSink writeMedium, int i) throws IOException {
Intrinsics.checkNotNullParameter(writeMedium, "$this$writeMedium");
writeMedium.writeByte((i >>> 16) & 255);
writeMedium.writeByte((i >>> 8) & 255);
writeMedium.writeByte(i & 255);
}
public static final int readMedium(BufferedSource readMedium) throws IOException {
Intrinsics.checkNotNullParameter(readMedium, "$this$readMedium");
return and(readMedium.readByte(), 255) | (and(readMedium.readByte(), 255) << 16) | (and(readMedium.readByte(), 255) << 8);
}
public static final boolean skipAll(Source skipAll, int i, TimeUnit timeUnit) throws IOException {
Intrinsics.checkNotNullParameter(skipAll, "$this$skipAll");
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
long nanoTime = System.nanoTime();
long deadlineNanoTime = skipAll.getTimeout().getHasDeadline() ? skipAll.getTimeout().deadlineNanoTime() - nanoTime : Long.MAX_VALUE;
skipAll.getTimeout().deadlineNanoTime(Math.min(deadlineNanoTime, timeUnit.toNanos(i)) + nanoTime);
try {
Buffer buffer = new Buffer();
while (skipAll.read(buffer, 8192L) != -1) {
buffer.clear();
}
if (deadlineNanoTime == Long.MAX_VALUE) {
skipAll.getTimeout().clearDeadline();
} else {
skipAll.getTimeout().deadlineNanoTime(nanoTime + deadlineNanoTime);
}
return true;
} catch (InterruptedIOException unused) {
if (deadlineNanoTime == Long.MAX_VALUE) {
skipAll.getTimeout().clearDeadline();
} else {
skipAll.getTimeout().deadlineNanoTime(nanoTime + deadlineNanoTime);
}
return false;
} catch (Throwable th) {
if (deadlineNanoTime == Long.MAX_VALUE) {
skipAll.getTimeout().clearDeadline();
} else {
skipAll.getTimeout().deadlineNanoTime(nanoTime + deadlineNanoTime);
}
throw th;
}
}
public static final boolean discard(Source discard, int i, TimeUnit timeUnit) {
Intrinsics.checkNotNullParameter(discard, "$this$discard");
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
try {
return skipAll(discard, i, timeUnit);
} catch (IOException unused) {
return false;
}
}
public static final String peerName(Socket peerName) {
Intrinsics.checkNotNullParameter(peerName, "$this$peerName");
SocketAddress remoteSocketAddress = peerName.getRemoteSocketAddress();
if (!(remoteSocketAddress instanceof InetSocketAddress)) {
return remoteSocketAddress.toString();
}
String hostName = ((InetSocketAddress) remoteSocketAddress).getHostName();
Intrinsics.checkNotNullExpressionValue(hostName, "address.hostName");
return hostName;
}
public static final boolean isHealthy(Socket isHealthy, BufferedSource source) {
Intrinsics.checkNotNullParameter(isHealthy, "$this$isHealthy");
Intrinsics.checkNotNullParameter(source, "source");
try {
int soTimeout = isHealthy.getSoTimeout();
try {
isHealthy.setSoTimeout(1);
boolean z = !source.exhausted();
isHealthy.setSoTimeout(soTimeout);
return z;
} catch (Throwable th) {
isHealthy.setSoTimeout(soTimeout);
throw th;
}
} catch (SocketTimeoutException unused) {
return true;
} catch (IOException unused2) {
return false;
}
}
public static final void ignoreIoExceptions(Function0<Unit> block) {
Intrinsics.checkNotNullParameter(block, "block");
try {
block.invoke();
} catch (IOException unused) {
}
}
public static final void threadName(String name, Function0<Unit> block) {
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(block, "block");
Thread currentThread = Thread.currentThread();
Intrinsics.checkNotNullExpressionValue(currentThread, "currentThread");
String name2 = currentThread.getName();
currentThread.setName(name);
try {
block.invoke();
} finally {
InlineMarker.finallyStart(1);
currentThread.setName(name2);
InlineMarker.finallyEnd(1);
}
}
public static final int skipAll(Buffer skipAll, byte b) {
Intrinsics.checkNotNullParameter(skipAll, "$this$skipAll");
int i = 0;
while (!skipAll.exhausted() && skipAll.getByte(0L) == b) {
i++;
skipAll.readByte();
}
return i;
}
public static /* synthetic */ int indexOfNonWhitespace$default(String str, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
i = 0;
}
return indexOfNonWhitespace(str, i);
}
public static final int indexOfNonWhitespace(String indexOfNonWhitespace, int i) {
Intrinsics.checkNotNullParameter(indexOfNonWhitespace, "$this$indexOfNonWhitespace");
int length = indexOfNonWhitespace.length();
while (i < length) {
char charAt = indexOfNonWhitespace.charAt(i);
if (charAt != ' ' && charAt != '\t') {
return i;
}
i++;
}
return indexOfNonWhitespace.length();
}
public static final long headersContentLength(Response headersContentLength) {
Intrinsics.checkNotNullParameter(headersContentLength, "$this$headersContentLength");
String str = headersContentLength.headers().get(HttpHeaders.CONTENT_LENGTH);
if (str != null) {
return toLongOrDefault(str, -1L);
}
return -1L;
}
public static final long toLongOrDefault(String toLongOrDefault, long j) {
Intrinsics.checkNotNullParameter(toLongOrDefault, "$this$toLongOrDefault");
try {
return Long.parseLong(toLongOrDefault);
} catch (NumberFormatException unused) {
return j;
}
}
public static final int toNonNegativeInt(String str, int i) {
if (str != null) {
try {
long parseLong = Long.parseLong(str);
if (parseLong > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
if (parseLong < 0) {
return 0;
}
return (int) parseLong;
} catch (NumberFormatException unused) {
}
}
return i;
}
public static final <T> List<T> toImmutableList(List<? extends T> toImmutableList) {
Intrinsics.checkNotNullParameter(toImmutableList, "$this$toImmutableList");
List<T> unmodifiableList = Collections.unmodifiableList(CollectionsKt.toMutableList((Collection) toImmutableList));
Intrinsics.checkNotNullExpressionValue(unmodifiableList, "Collections.unmodifiableList(toMutableList())");
return unmodifiableList;
}
@SafeVarargs
public static final <T> List<T> immutableListOf(T... elements) {
Intrinsics.checkNotNullParameter(elements, "elements");
Object[] objArr = (Object[]) elements.clone();
List<T> unmodifiableList = Collections.unmodifiableList(CollectionsKt.listOf(Arrays.copyOf(objArr, objArr.length)));
Intrinsics.checkNotNullExpressionValue(unmodifiableList, "Collections.unmodifiable…istOf(*elements.clone()))");
return unmodifiableList;
}
public static final <K, V> Map<K, V> toImmutableMap(Map<K, ? extends V> toImmutableMap) {
Intrinsics.checkNotNullParameter(toImmutableMap, "$this$toImmutableMap");
if (toImmutableMap.isEmpty()) {
return MapsKt.emptyMap();
}
Map<K, V> unmodifiableMap = Collections.unmodifiableMap(new LinkedHashMap(toImmutableMap));
Intrinsics.checkNotNullExpressionValue(unmodifiableMap, "Collections.unmodifiableMap(LinkedHashMap(this))");
return unmodifiableMap;
}
public static final void closeQuietly(Closeable closeQuietly) {
Intrinsics.checkNotNullParameter(closeQuietly, "$this$closeQuietly");
try {
closeQuietly.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception unused) {
}
}
public static final void closeQuietly(Socket closeQuietly) {
Intrinsics.checkNotNullParameter(closeQuietly, "$this$closeQuietly");
try {
closeQuietly.close();
} catch (AssertionError e) {
throw e;
} catch (RuntimeException e2) {
if (!Intrinsics.areEqual(e2.getMessage(), "bio == null")) {
throw e2;
}
} catch (Exception unused) {
}
}
public static final void closeQuietly(ServerSocket closeQuietly) {
Intrinsics.checkNotNullParameter(closeQuietly, "$this$closeQuietly");
try {
closeQuietly.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception unused) {
}
}
public static final boolean isCivilized(FileSystem isCivilized, File file) {
Intrinsics.checkNotNullParameter(isCivilized, "$this$isCivilized");
Intrinsics.checkNotNullParameter(file, "file");
Sink sink = isCivilized.sink(file);
try {
Sink sink2 = sink;
try {
isCivilized.delete(file);
CloseableKt.closeFinally(sink, null);
return true;
} catch (IOException unused) {
Unit unit = Unit.INSTANCE;
CloseableKt.closeFinally(sink, null);
isCivilized.delete(file);
return false;
}
} finally {
}
}
public static final String toHexString(long j) {
String hexString = Long.toHexString(j);
Intrinsics.checkNotNullExpressionValue(hexString, "java.lang.Long.toHexString(this)");
return hexString;
}
public static final String toHexString(int i) {
String hexString = Integer.toHexString(i);
Intrinsics.checkNotNullExpressionValue(hexString, "Integer.toHexString(this)");
return hexString;
}
public static final void wait(Object wait) {
Intrinsics.checkNotNullParameter(wait, "$this$wait");
wait.wait();
}
public static final void notify(Object notify) {
Intrinsics.checkNotNullParameter(notify, "$this$notify");
notify.notify();
}
public static final void notifyAll(Object notifyAll) {
Intrinsics.checkNotNullParameter(notifyAll, "$this$notifyAll");
notifyAll.notifyAll();
}
/* JADX WARN: Code restructure failed: missing block: B:10:0x0039, code lost:
return r3;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static final <T> T readFieldOrNull(java.lang.Object r5, java.lang.Class<T> r6, java.lang.String r7) {
/*
java.lang.String r0 = "instance"
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r5, r0)
java.lang.String r0 = "fieldType"
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r6, r0)
java.lang.String r0 = "fieldName"
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r7, r0)
java.lang.Class r0 = r5.getClass()
L13:
java.lang.Class<java.lang.Object> r1 = java.lang.Object.class
boolean r1 = kotlin.jvm.internal.Intrinsics.areEqual(r0, r1)
r2 = 1
r1 = r1 ^ r2
r3 = 0
if (r1 == 0) goto L44
java.lang.reflect.Field r1 = r0.getDeclaredField(r7) // Catch: java.lang.NoSuchFieldException -> L3a
java.lang.String r4 = "field"
kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r1, r4) // Catch: java.lang.NoSuchFieldException -> L3a
r1.setAccessible(r2) // Catch: java.lang.NoSuchFieldException -> L3a
java.lang.Object r1 = r1.get(r5) // Catch: java.lang.NoSuchFieldException -> L3a
boolean r2 = r6.isInstance(r1) // Catch: java.lang.NoSuchFieldException -> L3a
if (r2 != 0) goto L35
goto L39
L35:
java.lang.Object r3 = r6.cast(r1) // Catch: java.lang.NoSuchFieldException -> L3a
L39:
return r3
L3a:
java.lang.Class r0 = r0.getSuperclass()
java.lang.String r1 = "c.superclass"
kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r0, r1)
goto L13
L44:
java.lang.String r0 = "delegate"
boolean r1 = kotlin.jvm.internal.Intrinsics.areEqual(r7, r0)
r1 = r1 ^ r2
if (r1 == 0) goto L5a
java.lang.Class<java.lang.Object> r1 = java.lang.Object.class
java.lang.Object r5 = readFieldOrNull(r5, r1, r0)
if (r5 == 0) goto L5a
java.lang.Object r5 = readFieldOrNull(r5, r6, r7)
return r5
L5a:
return r3
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.Util.readFieldOrNull(java.lang.Object, java.lang.Class, java.lang.String):java.lang.Object");
}
public static final <E> void addIfAbsent(List<E> addIfAbsent, E e) {
Intrinsics.checkNotNullParameter(addIfAbsent, "$this$addIfAbsent");
if (addIfAbsent.contains(e)) {
return;
}
addIfAbsent.add(e);
}
public static final void assertThreadHoldsLock(Object assertThreadHoldsLock) {
Intrinsics.checkNotNullParameter(assertThreadHoldsLock, "$this$assertThreadHoldsLock");
if (!assertionsEnabled || Thread.holdsLock(assertThreadHoldsLock)) {
return;
}
StringBuilder sb = new StringBuilder("Thread ");
Thread currentThread = Thread.currentThread();
Intrinsics.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
throw new AssertionError(sb.append(currentThread.getName()).append(" MUST hold lock on ").append(assertThreadHoldsLock).toString());
}
public static final void assertThreadDoesntHoldLock(Object assertThreadDoesntHoldLock) {
Intrinsics.checkNotNullParameter(assertThreadDoesntHoldLock, "$this$assertThreadDoesntHoldLock");
if (assertionsEnabled && Thread.holdsLock(assertThreadDoesntHoldLock)) {
StringBuilder sb = new StringBuilder("Thread ");
Thread currentThread = Thread.currentThread();
Intrinsics.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
throw new AssertionError(sb.append(currentThread.getName()).append(" MUST NOT hold lock on ").append(assertThreadDoesntHoldLock).toString());
}
}
public static final Throwable withSuppressed(Exception withSuppressed, List<? extends Exception> suppressed) {
Intrinsics.checkNotNullParameter(withSuppressed, "$this$withSuppressed");
Intrinsics.checkNotNullParameter(suppressed, "suppressed");
if (suppressed.size() > 1) {
System.out.println(suppressed);
}
Iterator<? extends Exception> it = suppressed.iterator();
while (it.hasNext()) {
ExceptionsKt.addSuppressed(withSuppressed, it.next());
}
return withSuppressed;
}
public static final <T> List<T> filterList(Iterable<? extends T> filterList, Function1<? super T, Boolean> predicate) {
Intrinsics.checkNotNullParameter(filterList, "$this$filterList");
Intrinsics.checkNotNullParameter(predicate, "predicate");
ArrayList emptyList = CollectionsKt.emptyList();
for (T t : filterList) {
if (predicate.invoke(t).booleanValue()) {
if (emptyList.isEmpty()) {
emptyList = new ArrayList();
}
if (emptyList == null) {
throw new NullPointerException("null cannot be cast to non-null type kotlin.collections.MutableList<T>");
}
TypeIntrinsics.asMutableList(emptyList).add(t);
}
}
return emptyList;
}
public static final int indexOf(String[] indexOf, String value, Comparator<String> comparator) {
Intrinsics.checkNotNullParameter(indexOf, "$this$indexOf");
Intrinsics.checkNotNullParameter(value, "value");
Intrinsics.checkNotNullParameter(comparator, "comparator");
int length = indexOf.length;
for (int i = 0; i < length; i++) {
if (comparator.compare(indexOf[i], value) == 0) {
return i;
}
}
return -1;
}
}