485 lines
17 KiB
Java
485 lines
17 KiB
Java
package f0.f0;
|
|
|
|
import c.d.b.a.a;
|
|
import d0.g0.w;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import f0.c0;
|
|
import f0.f0.j.b;
|
|
import f0.x;
|
|
import g0.e;
|
|
import g0.g;
|
|
import g0.o;
|
|
import java.io.Closeable;
|
|
import java.io.IOException;
|
|
import java.io.InterruptedIOException;
|
|
import java.net.Socket;
|
|
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.List;
|
|
import java.util.Locale;
|
|
import java.util.TimeZone;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.TypeCastException;
|
|
import kotlin.text.Regex;
|
|
import okhttp3.Headers;
|
|
import okhttp3.RequestBody;
|
|
import okhttp3.Response;
|
|
import okhttp3.ResponseBody;
|
|
import okio.ByteString;
|
|
/* compiled from: Util.kt */
|
|
public final class c {
|
|
public static final byte[] a;
|
|
public static final Headers b = Headers.i.c(new String[0]);
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public static final ResponseBody f2716c;
|
|
public static final o d;
|
|
public static final TimeZone e;
|
|
public static final Regex f = new Regex("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");
|
|
public static final String g;
|
|
|
|
static {
|
|
byte[] bArr = new byte[0];
|
|
a = bArr;
|
|
m.checkParameterIsNotNull(bArr, "$this$toResponseBody");
|
|
e eVar = new e();
|
|
eVar.R(bArr);
|
|
m.checkParameterIsNotNull(eVar, "$this$asResponseBody");
|
|
f2716c = new c0(eVar, null, (long) 0);
|
|
RequestBody.Companion.d(RequestBody.Companion, bArr, null, 0, 0, 7);
|
|
o.a aVar = o.j;
|
|
ByteString.a aVar2 = ByteString.j;
|
|
d = aVar.c(aVar2.a("efbbbf"), aVar2.a("feff"), aVar2.a("fffe"), aVar2.a("0000ffff"), aVar2.a("ffff0000"));
|
|
TimeZone timeZone = TimeZone.getTimeZone("GMT");
|
|
if (timeZone == null) {
|
|
m.throwNpe();
|
|
}
|
|
e = timeZone;
|
|
String name = x.class.getName();
|
|
m.checkExpressionValueIsNotNull(name, "OkHttpClient::class.java.name");
|
|
g = w.removeSuffix(w.removePrefix(name, "okhttp3."), "Client");
|
|
}
|
|
|
|
public static final int A(String str, int i) {
|
|
if (str != null) {
|
|
try {
|
|
long parseLong = Long.parseLong(str);
|
|
if (parseLong > ((long) Integer.MAX_VALUE)) {
|
|
return Integer.MAX_VALUE;
|
|
}
|
|
if (parseLong < 0) {
|
|
return 0;
|
|
}
|
|
return (int) parseLong;
|
|
} catch (NumberFormatException unused) {
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static final String B(String str, int i, int i2) {
|
|
m.checkParameterIsNotNull(str, "$this$trimSubstring");
|
|
int o = o(str, i, i2);
|
|
String substring = str.substring(o, p(str, o, i2));
|
|
m.checkExpressionValueIsNotNull(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
|
|
return substring;
|
|
}
|
|
|
|
public static final Throwable C(Exception exc, List<? extends Exception> list) {
|
|
m.checkParameterIsNotNull(exc, "$this$withSuppressed");
|
|
m.checkParameterIsNotNull(list, "suppressed");
|
|
if (list.size() > 1) {
|
|
System.out.println(list);
|
|
}
|
|
for (Exception exc2 : list) {
|
|
exc.addSuppressed(exc2);
|
|
}
|
|
return exc;
|
|
}
|
|
|
|
public static final boolean a(f0.w wVar, f0.w wVar2) {
|
|
m.checkParameterIsNotNull(wVar, "$this$canReuseConnectionFor");
|
|
m.checkParameterIsNotNull(wVar2, "other");
|
|
return m.areEqual(wVar.g, wVar2.g) && wVar.h == wVar2.h && m.areEqual(wVar.d, wVar2.d);
|
|
}
|
|
|
|
public static final int b(String str, long j, TimeUnit timeUnit) {
|
|
m.checkParameterIsNotNull(str, "name");
|
|
boolean z2 = false;
|
|
int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
|
|
if (i >= 0) {
|
|
if (timeUnit != null) {
|
|
long millis = timeUnit.toMillis(j);
|
|
if (millis <= ((long) Integer.MAX_VALUE)) {
|
|
if (millis != 0 || i <= 0) {
|
|
z2 = true;
|
|
}
|
|
if (z2) {
|
|
return (int) millis;
|
|
}
|
|
throw new IllegalArgumentException(a.t(str, " too small.").toString());
|
|
}
|
|
throw new IllegalArgumentException(a.t(str, " too large.").toString());
|
|
}
|
|
throw new IllegalStateException("unit == null".toString());
|
|
}
|
|
throw new IllegalStateException(a.t(str, " < 0").toString());
|
|
}
|
|
|
|
public static final void c(long j, long j2, long j3) {
|
|
if ((j2 | j3) < 0 || j2 > j || j - j2 < j3) {
|
|
throw new ArrayIndexOutOfBoundsException();
|
|
}
|
|
}
|
|
|
|
public static final void d(Closeable closeable) {
|
|
m.checkParameterIsNotNull(closeable, "$this$closeQuietly");
|
|
try {
|
|
closeable.close();
|
|
} catch (RuntimeException e2) {
|
|
throw e2;
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
|
|
public static final void e(Socket socket) {
|
|
m.checkParameterIsNotNull(socket, "$this$closeQuietly");
|
|
try {
|
|
socket.close();
|
|
} catch (AssertionError e2) {
|
|
throw e2;
|
|
} catch (RuntimeException e3) {
|
|
throw e3;
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
|
|
public static final int f(String str, char c2, int i, int i2) {
|
|
m.checkParameterIsNotNull(str, "$this$delimiterOffset");
|
|
while (i < i2) {
|
|
if (str.charAt(i) == c2) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static final int g(String str, String str2, int i, int i2) {
|
|
m.checkParameterIsNotNull(str, "$this$delimiterOffset");
|
|
m.checkParameterIsNotNull(str2, "delimiters");
|
|
while (i < i2) {
|
|
if (w.contains$default((CharSequence) str2, str.charAt(i), false, 2, (Object) null)) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static /* synthetic */ int h(String str, char c2, int i, int i2, int i3) {
|
|
if ((i3 & 2) != 0) {
|
|
i = 0;
|
|
}
|
|
if ((i3 & 4) != 0) {
|
|
i2 = str.length();
|
|
}
|
|
return f(str, c2, i, i2);
|
|
}
|
|
|
|
public static final boolean i(g0.x xVar, int i, TimeUnit timeUnit) {
|
|
m.checkParameterIsNotNull(xVar, "$this$discard");
|
|
m.checkParameterIsNotNull(timeUnit, "timeUnit");
|
|
try {
|
|
return v(xVar, i, timeUnit);
|
|
} catch (IOException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static final String j(String str, Object... objArr) {
|
|
m.checkParameterIsNotNull(str, "format");
|
|
m.checkParameterIsNotNull(objArr, "args");
|
|
Locale locale = Locale.US;
|
|
m.checkExpressionValueIsNotNull(locale, "Locale.US");
|
|
Object[] copyOf = Arrays.copyOf(objArr, objArr.length);
|
|
String format = String.format(locale, str, Arrays.copyOf(copyOf, copyOf.length));
|
|
m.checkExpressionValueIsNotNull(format, "java.lang.String.format(locale, format, *args)");
|
|
return format;
|
|
}
|
|
|
|
public static final boolean k(String[] strArr, String[] strArr2, Comparator<? super String> comparator) {
|
|
m.checkParameterIsNotNull(strArr, "$this$hasIntersection");
|
|
m.checkParameterIsNotNull(comparator, "comparator");
|
|
if (!(strArr.length == 0) && strArr2 != null) {
|
|
if (!(strArr2.length == 0)) {
|
|
for (String str : strArr) {
|
|
for (String str2 : strArr2) {
|
|
if (comparator.compare(str, str2) == 0) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static final long l(Response response) {
|
|
m.checkParameterIsNotNull(response, "$this$headersContentLength");
|
|
String c2 = response.n.c("Content-Length");
|
|
if (c2 != null) {
|
|
m.checkParameterIsNotNull(c2, "$this$toLongOrDefault");
|
|
try {
|
|
return Long.parseLong(c2);
|
|
} catch (NumberFormatException unused) {
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@SafeVarargs
|
|
public static final <T> List<T> m(T... tArr) {
|
|
m.checkParameterIsNotNull(tArr, "elements");
|
|
Object[] objArr = (Object[]) tArr.clone();
|
|
List<T> unmodifiableList = Collections.unmodifiableList(Arrays.asList(Arrays.copyOf(objArr, objArr.length)));
|
|
m.checkExpressionValueIsNotNull(unmodifiableList, "Collections.unmodifiable…sList(*elements.clone()))");
|
|
return unmodifiableList;
|
|
}
|
|
|
|
public static final int n(String str) {
|
|
m.checkParameterIsNotNull(str, "$this$indexOfControlOrNonAscii");
|
|
int length = str.length();
|
|
for (int i = 0; i < length; i++) {
|
|
char charAt = str.charAt(i);
|
|
if (charAt <= 31 || charAt >= 127) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public static final int o(String str, int i, int i2) {
|
|
m.checkParameterIsNotNull(str, "$this$indexOfFirstNonAsciiWhitespace");
|
|
while (i < i2) {
|
|
char charAt = str.charAt(i);
|
|
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static final int p(String str, int i, int i2) {
|
|
m.checkParameterIsNotNull(str, "$this$indexOfLastNonAsciiWhitespace");
|
|
int i3 = i2 - 1;
|
|
if (i3 >= i) {
|
|
while (true) {
|
|
char charAt = str.charAt(i3);
|
|
if (charAt == '\t' || charAt == '\n' || charAt == '\f' || charAt == '\r' || charAt == ' ') {
|
|
if (i3 == i) {
|
|
break;
|
|
}
|
|
i3--;
|
|
} else {
|
|
return i3 + 1;
|
|
}
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static final String[] q(String[] strArr, String[] strArr2, Comparator<? super String> comparator) {
|
|
m.checkParameterIsNotNull(strArr, "$this$intersect");
|
|
m.checkParameterIsNotNull(strArr2, "other");
|
|
m.checkParameterIsNotNull(comparator, "comparator");
|
|
ArrayList arrayList = new ArrayList();
|
|
for (String str : strArr) {
|
|
int length = strArr2.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
break;
|
|
} else if (comparator.compare(str, strArr2[i]) == 0) {
|
|
arrayList.add(str);
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
Object[] array = arrayList.toArray(new String[0]);
|
|
if (array != null) {
|
|
return (String[]) array;
|
|
}
|
|
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
|
|
}
|
|
|
|
public static final int r(char c2) {
|
|
if ('0' <= c2 && '9' >= c2) {
|
|
return c2 - '0';
|
|
}
|
|
char c3 = 'a';
|
|
if ('a' > c2 || 'f' < c2) {
|
|
c3 = 'A';
|
|
if ('A' > c2 || 'F' < c2) {
|
|
return -1;
|
|
}
|
|
}
|
|
return (c2 - c3) + 10;
|
|
}
|
|
|
|
public static final Charset s(g gVar, Charset charset) throws IOException {
|
|
m.checkParameterIsNotNull(gVar, "$this$readBomAsCharset");
|
|
m.checkParameterIsNotNull(charset, "default");
|
|
int u0 = gVar.u0(d);
|
|
if (u0 == -1) {
|
|
return charset;
|
|
}
|
|
if (u0 == 0) {
|
|
Charset charset2 = StandardCharsets.UTF_8;
|
|
m.checkExpressionValueIsNotNull(charset2, "UTF_8");
|
|
return charset2;
|
|
} else if (u0 == 1) {
|
|
Charset charset3 = StandardCharsets.UTF_16BE;
|
|
m.checkExpressionValueIsNotNull(charset3, "UTF_16BE");
|
|
return charset3;
|
|
} else if (u0 == 2) {
|
|
Charset charset4 = StandardCharsets.UTF_16LE;
|
|
m.checkExpressionValueIsNotNull(charset4, "UTF_16LE");
|
|
return charset4;
|
|
} else if (u0 == 3) {
|
|
return d0.g0.c.d.UTF32_BE();
|
|
} else {
|
|
if (u0 == 4) {
|
|
return d0.g0.c.d.UTF32_LE();
|
|
}
|
|
throw new AssertionError();
|
|
}
|
|
}
|
|
|
|
public static final int t(g gVar) throws IOException {
|
|
m.checkParameterIsNotNull(gVar, "$this$readMedium");
|
|
return (gVar.readByte() & 255) | ((gVar.readByte() & 255) << 16) | ((gVar.readByte() & 255) << 8);
|
|
}
|
|
|
|
public static final int u(e eVar, byte b2) {
|
|
m.checkParameterIsNotNull(eVar, "$this$skipAll");
|
|
int i = 0;
|
|
while (!eVar.v() && eVar.r(0) == b2) {
|
|
i++;
|
|
eVar.readByte();
|
|
}
|
|
return i;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:11:0x0053, code lost:
|
|
if (r5 == Long.MAX_VALUE) goto L_0x0055;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0055, code lost:
|
|
r11.timeout().a();
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:13:0x005d, code lost:
|
|
r11.timeout().d(r0 + r5);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:22:0x0080, code lost:
|
|
if (r5 != Long.MAX_VALUE) goto L_0x005d;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:23:0x0083, code lost:
|
|
return r12;
|
|
*/
|
|
public static final boolean v(g0.x xVar, int i, TimeUnit timeUnit) throws IOException {
|
|
boolean z2;
|
|
m.checkParameterIsNotNull(xVar, "$this$skipAll");
|
|
m.checkParameterIsNotNull(timeUnit, "timeUnit");
|
|
long nanoTime = System.nanoTime();
|
|
long c2 = xVar.timeout().e() ? xVar.timeout().c() - nanoTime : Long.MAX_VALUE;
|
|
xVar.timeout().d(Math.min(c2, timeUnit.toNanos((long) i)) + nanoTime);
|
|
try {
|
|
e eVar = new e();
|
|
while (xVar.h0(eVar, 8192) != -1) {
|
|
eVar.skip(eVar.j);
|
|
}
|
|
z2 = true;
|
|
} catch (InterruptedIOException unused) {
|
|
z2 = false;
|
|
} catch (Throwable th) {
|
|
if (c2 == Long.MAX_VALUE) {
|
|
xVar.timeout().a();
|
|
} else {
|
|
xVar.timeout().d(nanoTime + c2);
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
public static final Headers w(List<b> list) {
|
|
m.checkParameterIsNotNull(list, "$this$toHeaders");
|
|
ArrayList arrayList = new ArrayList(20);
|
|
for (b bVar : list) {
|
|
ByteString byteString = bVar.h;
|
|
ByteString byteString2 = bVar.i;
|
|
String q = byteString.q();
|
|
String q2 = byteString2.q();
|
|
m.checkParameterIsNotNull(q, "name");
|
|
m.checkParameterIsNotNull(q2, "value");
|
|
arrayList.add(q);
|
|
arrayList.add(w.trim(q2).toString());
|
|
}
|
|
Object[] array = arrayList.toArray(new String[0]);
|
|
if (array != null) {
|
|
return new Headers((String[]) array, null);
|
|
}
|
|
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
|
|
}
|
|
|
|
public static final String x(int i) {
|
|
String hexString = Integer.toHexString(i);
|
|
m.checkExpressionValueIsNotNull(hexString, "Integer.toHexString(this)");
|
|
return hexString;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:19:? A[RETURN, SYNTHETIC] */
|
|
public static final String y(f0.w wVar, boolean z2) {
|
|
int i;
|
|
m.checkParameterIsNotNull(wVar, "$this$toHostHeader");
|
|
String C = w.contains$default(wVar.g, ":", false, 2, null) ? a.C(a.J('['), wVar.g, ']') : wVar.g;
|
|
if (!z2) {
|
|
int i2 = wVar.h;
|
|
String str = wVar.d;
|
|
m.checkParameterIsNotNull(str, "scheme");
|
|
int hashCode = str.hashCode();
|
|
if (hashCode != 3213448) {
|
|
if (hashCode == 99617003 && str.equals("https")) {
|
|
i = 443;
|
|
if (i2 == i) {
|
|
return C;
|
|
}
|
|
}
|
|
} else if (str.equals("http")) {
|
|
i = 80;
|
|
if (i2 == i) {
|
|
}
|
|
}
|
|
i = -1;
|
|
if (i2 == i) {
|
|
}
|
|
}
|
|
return C + ':' + wVar.h;
|
|
}
|
|
|
|
public static final <T> List<T> z(List<? extends T> list) {
|
|
m.checkParameterIsNotNull(list, "$this$toImmutableList");
|
|
List<T> unmodifiableList = Collections.unmodifiableList(u.toMutableList((Collection) list));
|
|
m.checkExpressionValueIsNotNull(unmodifiableList, "Collections.unmodifiableList(toMutableList())");
|
|
return unmodifiableList;
|
|
}
|
|
}
|