Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
package okhttp3;
import com.facebook.internal.security.CertificateUtil;
import com.ironsource.mediationsdk.logger.IronSourceError;
import java.net.Proxy;
import java.net.ProxySelector;
import java.util.List;
import java.util.Objects;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.HttpUrl;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class Address {
public final CertificatePinner certificatePinner;
public final List connectionSpecs;
public final Dns dns;
public final HostnameVerifier hostnameVerifier;
public final List protocols;
public final Proxy proxy;
public final Authenticator proxyAuthenticator;
public final ProxySelector proxySelector;
public final SocketFactory socketFactory;
public final SSLSocketFactory sslSocketFactory;
public final HttpUrl url;
public CertificatePinner certificatePinner() {
return this.certificatePinner;
}
public List connectionSpecs() {
return this.connectionSpecs;
}
public Dns dns() {
return this.dns;
}
public HostnameVerifier hostnameVerifier() {
return this.hostnameVerifier;
}
public List protocols() {
return this.protocols;
}
public Proxy proxy() {
return this.proxy;
}
public Authenticator proxyAuthenticator() {
return this.proxyAuthenticator;
}
public ProxySelector proxySelector() {
return this.proxySelector;
}
public SocketFactory socketFactory() {
return this.socketFactory;
}
public SSLSocketFactory sslSocketFactory() {
return this.sslSocketFactory;
}
public HttpUrl url() {
return this.url;
}
public Address(String str, int i, Dns dns, SocketFactory socketFactory, SSLSocketFactory sSLSocketFactory, HostnameVerifier hostnameVerifier, CertificatePinner certificatePinner, Authenticator authenticator, Proxy proxy, List list, List list2, ProxySelector proxySelector) {
this.url = new HttpUrl.Builder().scheme(sSLSocketFactory != null ? "https" : "http").host(str).port(i).build();
if (dns == null) {
throw new NullPointerException("dns == null");
}
this.dns = dns;
if (socketFactory == null) {
throw new NullPointerException("socketFactory == null");
}
this.socketFactory = socketFactory;
if (authenticator == null) {
throw new NullPointerException("proxyAuthenticator == null");
}
this.proxyAuthenticator = authenticator;
if (list == null) {
throw new NullPointerException("protocols == null");
}
this.protocols = Util.immutableList(list);
if (list2 == null) {
throw new NullPointerException("connectionSpecs == null");
}
this.connectionSpecs = Util.immutableList(list2);
if (proxySelector == null) {
throw new NullPointerException("proxySelector == null");
}
this.proxySelector = proxySelector;
this.proxy = proxy;
this.sslSocketFactory = sSLSocketFactory;
this.hostnameVerifier = hostnameVerifier;
this.certificatePinner = certificatePinner;
}
public boolean equals(Object obj) {
if (obj instanceof Address) {
Address address = (Address) obj;
if (this.url.equals(address.url) && equalsNonHost(address)) {
return true;
}
}
return false;
}
public int hashCode() {
return ((((((((((((((((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.url.hashCode()) * 31) + this.dns.hashCode()) * 31) + this.proxyAuthenticator.hashCode()) * 31) + this.protocols.hashCode()) * 31) + this.connectionSpecs.hashCode()) * 31) + this.proxySelector.hashCode()) * 31) + Objects.hashCode(this.proxy)) * 31) + Objects.hashCode(this.sslSocketFactory)) * 31) + Objects.hashCode(this.hostnameVerifier)) * 31) + Objects.hashCode(this.certificatePinner);
}
public boolean equalsNonHost(Address address) {
return this.dns.equals(address.dns) && this.proxyAuthenticator.equals(address.proxyAuthenticator) && this.protocols.equals(address.protocols) && this.connectionSpecs.equals(address.connectionSpecs) && this.proxySelector.equals(address.proxySelector) && Objects.equals(this.proxy, address.proxy) && Objects.equals(this.sslSocketFactory, address.sslSocketFactory) && Objects.equals(this.hostnameVerifier, address.hostnameVerifier) && Objects.equals(this.certificatePinner, address.certificatePinner) && url().port() == address.url().port();
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Address{");
sb.append(this.url.host());
sb.append(CertificateUtil.DELIMITER);
sb.append(this.url.port());
if (this.proxy != null) {
sb.append(", proxy=");
sb.append(this.proxy);
} else {
sb.append(", proxySelector=");
sb.append(this.proxySelector);
}
sb.append("}");
return sb.toString();
}
}

View File

@@ -0,0 +1,19 @@
package okhttp3;
/* loaded from: classes5.dex */
public interface Authenticator {
public static final Authenticator NONE = new Authenticator() { // from class: okhttp3.Authenticator$$ExternalSyntheticLambda0
@Override // okhttp3.Authenticator
public final Request authenticate(Route route, Response response) {
Request lambda$static$0;
lambda$static$0 = Authenticator.lambda$static$0(route, response);
return lambda$static$0;
}
};
static /* synthetic */ Request lambda$static$0(Route route, Response response) {
return null;
}
Request authenticate(Route route, Response response);
}

View File

@@ -0,0 +1,474 @@
package okhttp3;
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
import java.io.Closeable;
import java.io.File;
import java.io.Flushable;
import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import okhttp3.Headers;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Util;
import okhttp3.internal.cache.CacheRequest;
import okhttp3.internal.cache.CacheStrategy;
import okhttp3.internal.cache.DiskLruCache;
import okhttp3.internal.cache.InternalCache;
import okhttp3.internal.http.HttpHeaders;
import okhttp3.internal.http.HttpMethod;
import okhttp3.internal.http.StatusLine;
import okhttp3.internal.io.FileSystem;
import okhttp3.internal.platform.Platform;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.ByteString;
import okio.ForwardingSink;
import okio.ForwardingSource;
import okio.Okio;
import okio.Sink;
import okio.Source;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class Cache implements Closeable, Flushable {
public final DiskLruCache cache;
public int hitCount;
public final InternalCache internalCache;
public int networkCount;
public int requestCount;
public int writeAbortCount;
public int writeSuccessCount;
public Cache(File file, long j) {
this(file, j, FileSystem.SYSTEM);
}
public Cache(File file, long j, FileSystem fileSystem) {
this.internalCache = new InternalCache() { // from class: okhttp3.Cache.1
@Override // okhttp3.internal.cache.InternalCache
public Response get(Request request) {
return Cache.this.get(request);
}
@Override // okhttp3.internal.cache.InternalCache
public CacheRequest put(Response response) {
return Cache.this.put(response);
}
@Override // okhttp3.internal.cache.InternalCache
public void remove(Request request) {
Cache.this.remove(request);
}
@Override // okhttp3.internal.cache.InternalCache
public void update(Response response, Response response2) {
Cache.this.update(response, response2);
}
@Override // okhttp3.internal.cache.InternalCache
public void trackConditionalCacheHit() {
Cache.this.trackConditionalCacheHit();
}
@Override // okhttp3.internal.cache.InternalCache
public void trackResponse(CacheStrategy cacheStrategy) {
Cache.this.trackResponse(cacheStrategy);
}
};
this.cache = DiskLruCache.create(fileSystem, file, 201105, 2, j);
}
public static String key(HttpUrl httpUrl) {
return ByteString.encodeUtf8(httpUrl.toString()).md5().hex();
}
public Response get(Request request) {
try {
DiskLruCache.Snapshot snapshot = this.cache.get(key(request.url()));
if (snapshot == null) {
return null;
}
try {
Entry entry = new Entry(snapshot.getSource(0));
Response response = entry.response(snapshot);
if (entry.matches(request, response)) {
return response;
}
Util.closeQuietly(response.body());
return null;
} catch (IOException unused) {
Util.closeQuietly(snapshot);
return null;
}
} catch (IOException unused2) {
}
}
public CacheRequest put(Response response) {
DiskLruCache.Editor editor;
String method = response.request().method();
if (HttpMethod.invalidatesCache(response.request().method())) {
try {
remove(response.request());
} catch (IOException unused) {
}
return null;
}
if (!method.equals("GET") || HttpHeaders.hasVaryAll(response)) {
return null;
}
Entry entry = new Entry(response);
try {
editor = this.cache.edit(key(response.request().url()));
if (editor == null) {
return null;
}
try {
entry.writeTo(editor);
return new CacheRequestImpl(editor);
} catch (IOException unused2) {
abortQuietly(editor);
return null;
}
} catch (IOException unused3) {
editor = null;
}
}
public void remove(Request request) {
this.cache.remove(key(request.url()));
}
public void update(Response response, Response response2) {
DiskLruCache.Editor editor;
Entry entry = new Entry(response2);
try {
editor = ((CacheResponseBody) response.body()).snapshot.edit();
if (editor != null) {
try {
entry.writeTo(editor);
editor.commit();
} catch (IOException unused) {
abortQuietly(editor);
}
}
} catch (IOException unused2) {
editor = null;
}
}
public final void abortQuietly(DiskLruCache.Editor editor) {
if (editor != null) {
try {
editor.abort();
} catch (IOException unused) {
}
}
}
@Override // java.io.Flushable
public void flush() {
this.cache.flush();
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() {
this.cache.close();
}
public synchronized void trackResponse(CacheStrategy cacheStrategy) {
try {
this.requestCount++;
if (cacheStrategy.networkRequest != null) {
this.networkCount++;
} else if (cacheStrategy.cacheResponse != null) {
this.hitCount++;
}
} catch (Throwable th) {
throw th;
}
}
public synchronized void trackConditionalCacheHit() {
this.hitCount++;
}
public final class CacheRequestImpl implements CacheRequest {
public Sink body;
public Sink cacheOut;
public boolean done;
public final DiskLruCache.Editor editor;
@Override // okhttp3.internal.cache.CacheRequest
public Sink body() {
return this.body;
}
public CacheRequestImpl(final DiskLruCache.Editor editor) {
this.editor = editor;
Sink newSink = editor.newSink(1);
this.cacheOut = newSink;
this.body = new ForwardingSink(newSink) { // from class: okhttp3.Cache.CacheRequestImpl.1
@Override // okio.ForwardingSink, okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() {
synchronized (Cache.this) {
try {
CacheRequestImpl cacheRequestImpl = CacheRequestImpl.this;
if (cacheRequestImpl.done) {
return;
}
cacheRequestImpl.done = true;
Cache.this.writeSuccessCount++;
super.close();
editor.commit();
} catch (Throwable th) {
throw th;
}
}
}
};
}
@Override // okhttp3.internal.cache.CacheRequest
public void abort() {
synchronized (Cache.this) {
try {
if (this.done) {
return;
}
this.done = true;
Cache.this.writeAbortCount++;
Util.closeQuietly(this.cacheOut);
try {
this.editor.abort();
} catch (IOException unused) {
}
} catch (Throwable th) {
throw th;
}
}
}
}
public static final class Entry {
public final int code;
public final Handshake handshake;
public final String message;
public final Protocol protocol;
public final long receivedResponseMillis;
public final String requestMethod;
public final Headers responseHeaders;
public final long sentRequestMillis;
public final String url;
public final Headers varyHeaders;
public static final String SENT_MILLIS = Platform.get().getPrefix() + "-Sent-Millis";
public static final String RECEIVED_MILLIS = Platform.get().getPrefix() + "-Received-Millis";
public Entry(Source source) {
TlsVersion tlsVersion;
try {
BufferedSource buffer = Okio.buffer(source);
this.url = buffer.readUtf8LineStrict();
this.requestMethod = buffer.readUtf8LineStrict();
Headers.Builder builder = new Headers.Builder();
int readInt = Cache.readInt(buffer);
for (int i = 0; i < readInt; i++) {
builder.addLenient(buffer.readUtf8LineStrict());
}
this.varyHeaders = builder.build();
StatusLine parse = StatusLine.parse(buffer.readUtf8LineStrict());
this.protocol = parse.protocol;
this.code = parse.code;
this.message = parse.message;
Headers.Builder builder2 = new Headers.Builder();
int readInt2 = Cache.readInt(buffer);
for (int i2 = 0; i2 < readInt2; i2++) {
builder2.addLenient(buffer.readUtf8LineStrict());
}
String str = SENT_MILLIS;
String str2 = builder2.get(str);
String str3 = RECEIVED_MILLIS;
String str4 = builder2.get(str3);
builder2.removeAll(str);
builder2.removeAll(str3);
this.sentRequestMillis = str2 != null ? Long.parseLong(str2) : 0L;
this.receivedResponseMillis = str4 != null ? Long.parseLong(str4) : 0L;
this.responseHeaders = builder2.build();
if (isHttps()) {
String readUtf8LineStrict = buffer.readUtf8LineStrict();
if (readUtf8LineStrict.length() > 0) {
throw new IOException("expected \"\" but was \"" + readUtf8LineStrict + "\"");
}
CipherSuite forJavaName = CipherSuite.forJavaName(buffer.readUtf8LineStrict());
List readCertificateList = readCertificateList(buffer);
List readCertificateList2 = readCertificateList(buffer);
if (!buffer.exhausted()) {
tlsVersion = TlsVersion.forJavaName(buffer.readUtf8LineStrict());
} else {
tlsVersion = TlsVersion.SSL_3_0;
}
this.handshake = Handshake.get(tlsVersion, forJavaName, readCertificateList, readCertificateList2);
} else {
this.handshake = null;
}
source.close();
} catch (Throwable th) {
source.close();
throw th;
}
}
public Entry(Response response) {
this.url = response.request().url().toString();
this.varyHeaders = HttpHeaders.varyHeaders(response);
this.requestMethod = response.request().method();
this.protocol = response.protocol();
this.code = response.code();
this.message = response.message();
this.responseHeaders = response.headers();
this.handshake = response.handshake();
this.sentRequestMillis = response.sentRequestAtMillis();
this.receivedResponseMillis = response.receivedResponseAtMillis();
}
public void writeTo(DiskLruCache.Editor editor) {
BufferedSink buffer = Okio.buffer(editor.newSink(0));
buffer.writeUtf8(this.url).writeByte(10);
buffer.writeUtf8(this.requestMethod).writeByte(10);
buffer.writeDecimalLong(this.varyHeaders.size()).writeByte(10);
int size = this.varyHeaders.size();
for (int i = 0; i < size; i++) {
buffer.writeUtf8(this.varyHeaders.name(i)).writeUtf8(": ").writeUtf8(this.varyHeaders.value(i)).writeByte(10);
}
buffer.writeUtf8(new StatusLine(this.protocol, this.code, this.message).toString()).writeByte(10);
buffer.writeDecimalLong(this.responseHeaders.size() + 2).writeByte(10);
int size2 = this.responseHeaders.size();
for (int i2 = 0; i2 < size2; i2++) {
buffer.writeUtf8(this.responseHeaders.name(i2)).writeUtf8(": ").writeUtf8(this.responseHeaders.value(i2)).writeByte(10);
}
buffer.writeUtf8(SENT_MILLIS).writeUtf8(": ").writeDecimalLong(this.sentRequestMillis).writeByte(10);
buffer.writeUtf8(RECEIVED_MILLIS).writeUtf8(": ").writeDecimalLong(this.receivedResponseMillis).writeByte(10);
if (isHttps()) {
buffer.writeByte(10);
buffer.writeUtf8(this.handshake.cipherSuite().javaName()).writeByte(10);
writeCertList(buffer, this.handshake.peerCertificates());
writeCertList(buffer, this.handshake.localCertificates());
buffer.writeUtf8(this.handshake.tlsVersion().javaName()).writeByte(10);
}
buffer.close();
}
public final boolean isHttps() {
return this.url.startsWith("https://");
}
public final List readCertificateList(BufferedSource bufferedSource) {
int readInt = Cache.readInt(bufferedSource);
if (readInt == -1) {
return Collections.emptyList();
}
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance(AndroidStaticDeviceInfoDataSource.CERTIFICATE_TYPE_X509);
ArrayList arrayList = new ArrayList(readInt);
for (int i = 0; i < readInt; i++) {
String readUtf8LineStrict = bufferedSource.readUtf8LineStrict();
Buffer buffer = new Buffer();
buffer.write(ByteString.decodeBase64(readUtf8LineStrict));
arrayList.add(certificateFactory.generateCertificate(buffer.inputStream()));
}
return arrayList;
} catch (CertificateException e) {
throw new IOException(e.getMessage());
}
}
public final void writeCertList(BufferedSink bufferedSink, List list) {
try {
bufferedSink.writeDecimalLong(list.size()).writeByte(10);
int size = list.size();
for (int i = 0; i < size; i++) {
bufferedSink.writeUtf8(ByteString.of(((Certificate) list.get(i)).getEncoded()).base64()).writeByte(10);
}
} catch (CertificateEncodingException e) {
throw new IOException(e.getMessage());
}
}
public boolean matches(Request request, Response response) {
return this.url.equals(request.url().toString()) && this.requestMethod.equals(request.method()) && HttpHeaders.varyMatches(response, this.varyHeaders, request);
}
public Response response(DiskLruCache.Snapshot snapshot) {
String str = this.responseHeaders.get("Content-Type");
String str2 = this.responseHeaders.get(HTTP.CONTENT_LEN);
return new Response.Builder().request(new Request.Builder().url(this.url).method(this.requestMethod, null).headers(this.varyHeaders).build()).protocol(this.protocol).code(this.code).message(this.message).headers(this.responseHeaders).body(new CacheResponseBody(snapshot, str, str2)).handshake(this.handshake).sentRequestAtMillis(this.sentRequestMillis).receivedResponseAtMillis(this.receivedResponseMillis).build();
}
}
public static int readInt(BufferedSource bufferedSource) {
try {
long readDecimalLong = bufferedSource.readDecimalLong();
String readUtf8LineStrict = bufferedSource.readUtf8LineStrict();
if (readDecimalLong >= 0 && readDecimalLong <= 2147483647L && readUtf8LineStrict.isEmpty()) {
return (int) readDecimalLong;
}
throw new IOException("expected an int but was \"" + readDecimalLong + readUtf8LineStrict + "\"");
} catch (NumberFormatException e) {
throw new IOException(e.getMessage());
}
}
public static class CacheResponseBody extends ResponseBody {
public final BufferedSource bodySource;
public final String contentLength;
public final String contentType;
public final DiskLruCache.Snapshot snapshot;
@Override // okhttp3.ResponseBody
public BufferedSource source() {
return this.bodySource;
}
public CacheResponseBody(final DiskLruCache.Snapshot snapshot, String str, String str2) {
this.snapshot = snapshot;
this.contentType = str;
this.contentLength = str2;
this.bodySource = Okio.buffer(new ForwardingSource(snapshot.getSource(1)) { // from class: okhttp3.Cache.CacheResponseBody.1
@Override // okio.ForwardingSource, okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
snapshot.close();
super.close();
}
});
}
@Override // okhttp3.ResponseBody
public MediaType contentType() {
String str = this.contentType;
if (str != null) {
return MediaType.parse(str);
}
return null;
}
@Override // okhttp3.ResponseBody
public long contentLength() {
try {
String str = this.contentLength;
if (str != null) {
return Long.parseLong(str);
}
return -1L;
} catch (NumberFormatException unused) {
return -1L;
}
}
}
}

View File

@@ -0,0 +1,199 @@
package okhttp3;
import java.util.concurrent.TimeUnit;
/* loaded from: classes5.dex */
public final class CacheControl {
public String headerValue;
public final boolean immutable;
public final boolean isPrivate;
public final boolean isPublic;
public final int maxAgeSeconds;
public final int maxStaleSeconds;
public final int minFreshSeconds;
public final boolean mustRevalidate;
public final boolean noCache;
public final boolean noStore;
public final boolean noTransform;
public final boolean onlyIfCached;
public final int sMaxAgeSeconds;
public static final CacheControl FORCE_NETWORK = new Builder().noCache().build();
public static final CacheControl FORCE_CACHE = new Builder().onlyIfCached().maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS).build();
public boolean isPrivate() {
return this.isPrivate;
}
public boolean isPublic() {
return this.isPublic;
}
public int maxAgeSeconds() {
return this.maxAgeSeconds;
}
public int maxStaleSeconds() {
return this.maxStaleSeconds;
}
public int minFreshSeconds() {
return this.minFreshSeconds;
}
public boolean mustRevalidate() {
return this.mustRevalidate;
}
public boolean noCache() {
return this.noCache;
}
public boolean noStore() {
return this.noStore;
}
public boolean onlyIfCached() {
return this.onlyIfCached;
}
public CacheControl(boolean z, boolean z2, int i, int i2, boolean z3, boolean z4, boolean z5, int i3, int i4, boolean z6, boolean z7, boolean z8, String str) {
this.noCache = z;
this.noStore = z2;
this.maxAgeSeconds = i;
this.sMaxAgeSeconds = i2;
this.isPrivate = z3;
this.isPublic = z4;
this.mustRevalidate = z5;
this.maxStaleSeconds = i3;
this.minFreshSeconds = i4;
this.onlyIfCached = z6;
this.noTransform = z7;
this.immutable = z8;
this.headerValue = str;
}
public CacheControl(Builder builder) {
this.noCache = builder.noCache;
this.noStore = builder.noStore;
this.maxAgeSeconds = builder.maxAgeSeconds;
this.sMaxAgeSeconds = -1;
this.isPrivate = false;
this.isPublic = false;
this.mustRevalidate = false;
this.maxStaleSeconds = builder.maxStaleSeconds;
this.minFreshSeconds = builder.minFreshSeconds;
this.onlyIfCached = builder.onlyIfCached;
this.noTransform = builder.noTransform;
this.immutable = builder.immutable;
}
/* JADX WARN: Removed duplicated region for block: B:10:0x0042 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static okhttp3.CacheControl parse(okhttp3.Headers r22) {
/*
Method dump skipped, instructions count: 341
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.CacheControl.parse(okhttp3.Headers):okhttp3.CacheControl");
}
public String toString() {
String str = this.headerValue;
if (str != null) {
return str;
}
String headerValue = headerValue();
this.headerValue = headerValue;
return headerValue;
}
public final String headerValue() {
StringBuilder sb = new StringBuilder();
if (this.noCache) {
sb.append("no-cache, ");
}
if (this.noStore) {
sb.append("no-store, ");
}
if (this.maxAgeSeconds != -1) {
sb.append("max-age=");
sb.append(this.maxAgeSeconds);
sb.append(", ");
}
if (this.sMaxAgeSeconds != -1) {
sb.append("s-maxage=");
sb.append(this.sMaxAgeSeconds);
sb.append(", ");
}
if (this.isPrivate) {
sb.append("private, ");
}
if (this.isPublic) {
sb.append("public, ");
}
if (this.mustRevalidate) {
sb.append("must-revalidate, ");
}
if (this.maxStaleSeconds != -1) {
sb.append("max-stale=");
sb.append(this.maxStaleSeconds);
sb.append(", ");
}
if (this.minFreshSeconds != -1) {
sb.append("min-fresh=");
sb.append(this.minFreshSeconds);
sb.append(", ");
}
if (this.onlyIfCached) {
sb.append("only-if-cached, ");
}
if (this.noTransform) {
sb.append("no-transform, ");
}
if (this.immutable) {
sb.append("immutable, ");
}
if (sb.length() == 0) {
return "";
}
sb.delete(sb.length() - 2, sb.length());
return sb.toString();
}
public static final class Builder {
public boolean immutable;
public int maxAgeSeconds = -1;
public int maxStaleSeconds = -1;
public int minFreshSeconds = -1;
public boolean noCache;
public boolean noStore;
public boolean noTransform;
public boolean onlyIfCached;
public Builder noCache() {
this.noCache = true;
return this;
}
public Builder onlyIfCached() {
this.onlyIfCached = true;
return this;
}
public Builder maxStale(int i, TimeUnit timeUnit) {
if (i < 0) {
throw new IllegalArgumentException("maxStale < 0: " + i);
}
long seconds = timeUnit.toSeconds(i);
this.maxStaleSeconds = seconds > 2147483647L ? Integer.MAX_VALUE : (int) seconds;
return this;
}
public CacheControl build() {
return new CacheControl(this);
}
}
}

View File

@@ -0,0 +1,19 @@
package okhttp3;
/* loaded from: classes5.dex */
public interface Call extends Cloneable {
public interface Factory {
Call newCall(Request request);
}
void cancel();
void enqueue(Callback callback);
Response execute();
boolean isCanceled();
Request request();
}

View File

@@ -0,0 +1,10 @@
package okhttp3;
import java.io.IOException;
/* loaded from: classes5.dex */
public interface Callback {
void onFailure(Call call, IOException iOException);
void onResponse(Call call, Response response);
}

View File

@@ -0,0 +1,117 @@
package okhttp3;
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
import com.facebook.internal.security.CertificateUtil;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.net.ssl.SSLPeerUnverifiedException;
import okhttp3.internal.tls.CertificateChainCleaner;
import okio.ByteString;
/* loaded from: classes5.dex */
public final class CertificatePinner {
public static final CertificatePinner DEFAULT = new Builder().build();
public final CertificateChainCleaner certificateChainCleaner;
public final Set pins;
public CertificatePinner(Set set, CertificateChainCleaner certificateChainCleaner) {
this.pins = set;
this.certificateChainCleaner = certificateChainCleaner;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof CertificatePinner) {
CertificatePinner certificatePinner = (CertificatePinner) obj;
if (Objects.equals(this.certificateChainCleaner, certificatePinner.certificateChainCleaner) && this.pins.equals(certificatePinner.pins)) {
return true;
}
}
return false;
}
public int hashCode() {
return (Objects.hashCode(this.certificateChainCleaner) * 31) + this.pins.hashCode();
}
public void check(String str, List list) {
List findMatchingPins = findMatchingPins(str);
if (findMatchingPins.isEmpty()) {
return;
}
CertificateChainCleaner certificateChainCleaner = this.certificateChainCleaner;
if (certificateChainCleaner != null) {
list = certificateChainCleaner.clean(list, str);
}
int size = list.size();
for (int i = 0; i < size; i++) {
if (findMatchingPins.size() > 0) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(findMatchingPins.get(0));
throw null;
}
}
StringBuilder sb = new StringBuilder();
sb.append("Certificate pinning failure!");
sb.append("\n Peer certificate chain:");
int size2 = list.size();
for (int i2 = 0; i2 < size2; i2++) {
X509Certificate x509Certificate = (X509Certificate) list.get(i2);
sb.append("\n ");
sb.append(pin(x509Certificate));
sb.append(": ");
sb.append(x509Certificate.getSubjectDN().getName());
}
sb.append("\n Pinned certificates for ");
sb.append(str);
sb.append(CertificateUtil.DELIMITER);
int size3 = findMatchingPins.size();
for (int i3 = 0; i3 < size3; i3++) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(findMatchingPins.get(i3));
sb.append("\n ");
sb.append((Object) null);
}
throw new SSLPeerUnverifiedException(sb.toString());
}
public List findMatchingPins(String str) {
List emptyList = Collections.emptyList();
Iterator it = this.pins.iterator();
if (!it.hasNext()) {
return emptyList;
}
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(it.next());
throw null;
}
public CertificatePinner withCertificateChainCleaner(CertificateChainCleaner certificateChainCleaner) {
return Objects.equals(this.certificateChainCleaner, certificateChainCleaner) ? this : new CertificatePinner(this.pins, certificateChainCleaner);
}
public static String pin(Certificate certificate) {
if (!(certificate instanceof X509Certificate)) {
throw new IllegalArgumentException("Certificate pinning requires X509 certificates");
}
return "sha256/" + sha256((X509Certificate) certificate).base64();
}
public static ByteString sha256(X509Certificate x509Certificate) {
return ByteString.of(x509Certificate.getPublicKey().getEncoded()).sha256();
}
public static final class Builder {
public final List pins = new ArrayList();
public CertificatePinner build() {
return new CertificatePinner(new LinkedHashSet(this.pins), null);
}
}
}

View File

@@ -0,0 +1,217 @@
package okhttp3;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import com.vungle.ads.internal.signals.SignalKey;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes5.dex */
public final class CipherSuite {
public final String javaName;
public static final Comparator ORDER_BY_NAME = new Comparator() { // from class: okhttp3.CipherSuite$$ExternalSyntheticLambda0
@Override // java.util.Comparator
public final int compare(Object obj, Object obj2) {
int lambda$static$0;
lambda$static$0 = CipherSuite.lambda$static$0((String) obj, (String) obj2);
return lambda$static$0;
}
};
public static final Map INSTANCES = new LinkedHashMap();
public static final CipherSuite TLS_RSA_WITH_NULL_MD5 = init("SSL_RSA_WITH_NULL_MD5", 1);
public static final CipherSuite TLS_RSA_WITH_NULL_SHA = init("SSL_RSA_WITH_NULL_SHA", 2);
public static final CipherSuite TLS_RSA_EXPORT_WITH_RC4_40_MD5 = init("SSL_RSA_EXPORT_WITH_RC4_40_MD5", 3);
public static final CipherSuite TLS_RSA_WITH_RC4_128_MD5 = init("SSL_RSA_WITH_RC4_128_MD5", 4);
public static final CipherSuite TLS_RSA_WITH_RC4_128_SHA = init("SSL_RSA_WITH_RC4_128_SHA", 5);
public static final CipherSuite TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = init("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", 8);
public static final CipherSuite TLS_RSA_WITH_DES_CBC_SHA = init("SSL_RSA_WITH_DES_CBC_SHA", 9);
public static final CipherSuite TLS_RSA_WITH_3DES_EDE_CBC_SHA = init("SSL_RSA_WITH_3DES_EDE_CBC_SHA", 10);
public static final CipherSuite TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = init("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", 17);
public static final CipherSuite TLS_DHE_DSS_WITH_DES_CBC_SHA = init("SSL_DHE_DSS_WITH_DES_CBC_SHA", 18);
public static final CipherSuite TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = init("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", 19);
public static final CipherSuite TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = init("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", 20);
public static final CipherSuite TLS_DHE_RSA_WITH_DES_CBC_SHA = init("SSL_DHE_RSA_WITH_DES_CBC_SHA", 21);
public static final CipherSuite TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = init("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", 22);
public static final CipherSuite TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = init("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 23);
public static final CipherSuite TLS_DH_anon_WITH_RC4_128_MD5 = init("SSL_DH_anon_WITH_RC4_128_MD5", 24);
public static final CipherSuite TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = init("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 25);
public static final CipherSuite TLS_DH_anon_WITH_DES_CBC_SHA = init("SSL_DH_anon_WITH_DES_CBC_SHA", 26);
public static final CipherSuite TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = init("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", 27);
public static final CipherSuite TLS_KRB5_WITH_DES_CBC_SHA = init("TLS_KRB5_WITH_DES_CBC_SHA", 30);
public static final CipherSuite TLS_KRB5_WITH_3DES_EDE_CBC_SHA = init("TLS_KRB5_WITH_3DES_EDE_CBC_SHA", 31);
public static final CipherSuite TLS_KRB5_WITH_RC4_128_SHA = init("TLS_KRB5_WITH_RC4_128_SHA", 32);
public static final CipherSuite TLS_KRB5_WITH_DES_CBC_MD5 = init("TLS_KRB5_WITH_DES_CBC_MD5", 34);
public static final CipherSuite TLS_KRB5_WITH_3DES_EDE_CBC_MD5 = init("TLS_KRB5_WITH_3DES_EDE_CBC_MD5", 35);
public static final CipherSuite TLS_KRB5_WITH_RC4_128_MD5 = init("TLS_KRB5_WITH_RC4_128_MD5", 36);
public static final CipherSuite TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA = init("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 38);
public static final CipherSuite TLS_KRB5_EXPORT_WITH_RC4_40_SHA = init("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", 40);
public static final CipherSuite TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 = init("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 41);
public static final CipherSuite TLS_KRB5_EXPORT_WITH_RC4_40_MD5 = init("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", 43);
public static final CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA = init("TLS_RSA_WITH_AES_128_CBC_SHA", 47);
public static final CipherSuite TLS_DHE_DSS_WITH_AES_128_CBC_SHA = init("TLS_DHE_DSS_WITH_AES_128_CBC_SHA", 50);
public static final CipherSuite TLS_DHE_RSA_WITH_AES_128_CBC_SHA = init("TLS_DHE_RSA_WITH_AES_128_CBC_SHA", 51);
public static final CipherSuite TLS_DH_anon_WITH_AES_128_CBC_SHA = init("TLS_DH_anon_WITH_AES_128_CBC_SHA", 52);
public static final CipherSuite TLS_RSA_WITH_AES_256_CBC_SHA = init("TLS_RSA_WITH_AES_256_CBC_SHA", 53);
public static final CipherSuite TLS_DHE_DSS_WITH_AES_256_CBC_SHA = init("TLS_DHE_DSS_WITH_AES_256_CBC_SHA", 56);
public static final CipherSuite TLS_DHE_RSA_WITH_AES_256_CBC_SHA = init("TLS_DHE_RSA_WITH_AES_256_CBC_SHA", 57);
public static final CipherSuite TLS_DH_anon_WITH_AES_256_CBC_SHA = init("TLS_DH_anon_WITH_AES_256_CBC_SHA", 58);
public static final CipherSuite TLS_RSA_WITH_NULL_SHA256 = init("TLS_RSA_WITH_NULL_SHA256", 59);
public static final CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA256 = init("TLS_RSA_WITH_AES_128_CBC_SHA256", 60);
public static final CipherSuite TLS_RSA_WITH_AES_256_CBC_SHA256 = init("TLS_RSA_WITH_AES_256_CBC_SHA256", 61);
public static final CipherSuite TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = init("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", 64);
public static final CipherSuite TLS_RSA_WITH_CAMELLIA_128_CBC_SHA = init("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", 65);
public static final CipherSuite TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA = init("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", 68);
public static final CipherSuite TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA = init("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", 69);
public static final CipherSuite TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = init("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", 103);
public static final CipherSuite TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = init("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", 106);
public static final CipherSuite TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = init("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", SignalKey.EVENT_ID);
public static final CipherSuite TLS_DH_anon_WITH_AES_128_CBC_SHA256 = init("TLS_DH_anon_WITH_AES_128_CBC_SHA256", 108);
public static final CipherSuite TLS_DH_anon_WITH_AES_256_CBC_SHA256 = init("TLS_DH_anon_WITH_AES_256_CBC_SHA256", 109);
public static final CipherSuite TLS_RSA_WITH_CAMELLIA_256_CBC_SHA = init("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", 132);
public static final CipherSuite TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA = init("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", 135);
public static final CipherSuite TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA = init("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", 136);
public static final CipherSuite TLS_PSK_WITH_RC4_128_SHA = init("TLS_PSK_WITH_RC4_128_SHA", 138);
public static final CipherSuite TLS_PSK_WITH_3DES_EDE_CBC_SHA = init("TLS_PSK_WITH_3DES_EDE_CBC_SHA", 139);
public static final CipherSuite TLS_PSK_WITH_AES_128_CBC_SHA = init("TLS_PSK_WITH_AES_128_CBC_SHA", IronSourceConstants.USING_CACHE_FOR_INIT_EVENT);
public static final CipherSuite TLS_PSK_WITH_AES_256_CBC_SHA = init("TLS_PSK_WITH_AES_256_CBC_SHA", 141);
public static final CipherSuite TLS_RSA_WITH_SEED_CBC_SHA = init("TLS_RSA_WITH_SEED_CBC_SHA", IronSourceConstants.REWARDED_VIDEO_DAILY_CAPPED);
public static final CipherSuite TLS_RSA_WITH_AES_128_GCM_SHA256 = init("TLS_RSA_WITH_AES_128_GCM_SHA256", 156);
public static final CipherSuite TLS_RSA_WITH_AES_256_GCM_SHA384 = init("TLS_RSA_WITH_AES_256_GCM_SHA384", 157);
public static final CipherSuite TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = init("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", 158);
public static final CipherSuite TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = init("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", 159);
public static final CipherSuite TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 = init("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", 162);
public static final CipherSuite TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 = init("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", 163);
public static final CipherSuite TLS_DH_anon_WITH_AES_128_GCM_SHA256 = init("TLS_DH_anon_WITH_AES_128_GCM_SHA256", 166);
public static final CipherSuite TLS_DH_anon_WITH_AES_256_GCM_SHA384 = init("TLS_DH_anon_WITH_AES_256_GCM_SHA384", 167);
public static final CipherSuite TLS_EMPTY_RENEGOTIATION_INFO_SCSV = init("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", 255);
public static final CipherSuite TLS_FALLBACK_SCSV = init("TLS_FALLBACK_SCSV", 22016);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_NULL_SHA = init("TLS_ECDH_ECDSA_WITH_NULL_SHA", 49153);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_RC4_128_SHA = init("TLS_ECDH_ECDSA_WITH_RC4_128_SHA", 49154);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA = init("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", 49155);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = init("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", 49156);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA = init("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", 49157);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_NULL_SHA = init("TLS_ECDHE_ECDSA_WITH_NULL_SHA", 49158);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_RC4_128_SHA = init("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", 49159);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = init("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", 49160);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = init("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", 49161);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = init("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", 49162);
public static final CipherSuite TLS_ECDH_RSA_WITH_NULL_SHA = init("TLS_ECDH_RSA_WITH_NULL_SHA", 49163);
public static final CipherSuite TLS_ECDH_RSA_WITH_RC4_128_SHA = init("TLS_ECDH_RSA_WITH_RC4_128_SHA", 49164);
public static final CipherSuite TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA = init("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", 49165);
public static final CipherSuite TLS_ECDH_RSA_WITH_AES_128_CBC_SHA = init("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", 49166);
public static final CipherSuite TLS_ECDH_RSA_WITH_AES_256_CBC_SHA = init("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", 49167);
public static final CipherSuite TLS_ECDHE_RSA_WITH_NULL_SHA = init("TLS_ECDHE_RSA_WITH_NULL_SHA", 49168);
public static final CipherSuite TLS_ECDHE_RSA_WITH_RC4_128_SHA = init("TLS_ECDHE_RSA_WITH_RC4_128_SHA", 49169);
public static final CipherSuite TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA = init("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", 49170);
public static final CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = init("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", 49171);
public static final CipherSuite TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = init("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", 49172);
public static final CipherSuite TLS_ECDH_anon_WITH_NULL_SHA = init("TLS_ECDH_anon_WITH_NULL_SHA", 49173);
public static final CipherSuite TLS_ECDH_anon_WITH_RC4_128_SHA = init("TLS_ECDH_anon_WITH_RC4_128_SHA", 49174);
public static final CipherSuite TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = init("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", 49175);
public static final CipherSuite TLS_ECDH_anon_WITH_AES_128_CBC_SHA = init("TLS_ECDH_anon_WITH_AES_128_CBC_SHA", 49176);
public static final CipherSuite TLS_ECDH_anon_WITH_AES_256_CBC_SHA = init("TLS_ECDH_anon_WITH_AES_256_CBC_SHA", 49177);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = init("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", 49187);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = init("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", 49188);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 = init("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", 49189);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 = init("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", 49190);
public static final CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = init("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", 49191);
public static final CipherSuite TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = init("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", 49192);
public static final CipherSuite TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 = init("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", 49193);
public static final CipherSuite TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 = init("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", 49194);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = init("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", 49195);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = init("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", 49196);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = init("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", 49197);
public static final CipherSuite TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = init("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", 49198);
public static final CipherSuite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = init("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", 49199);
public static final CipherSuite TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = init("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", 49200);
public static final CipherSuite TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 = init("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", 49201);
public static final CipherSuite TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 = init("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", 49202);
public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = init("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", 49205);
public static final CipherSuite TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = init("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", 49206);
public static final CipherSuite TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = init("TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", 52392);
public static final CipherSuite TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = init("TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", 52393);
public static final CipherSuite TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = init("TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256", 52394);
public static final CipherSuite TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 = init("TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256", 52396);
public static final CipherSuite TLS_AES_128_GCM_SHA256 = init("TLS_AES_128_GCM_SHA256", 4865);
public static final CipherSuite TLS_AES_256_GCM_SHA384 = init("TLS_AES_256_GCM_SHA384", 4866);
public static final CipherSuite TLS_CHACHA20_POLY1305_SHA256 = init("TLS_CHACHA20_POLY1305_SHA256", 4867);
public static final CipherSuite TLS_AES_128_CCM_SHA256 = init("TLS_AES_128_CCM_SHA256", 4868);
public static final CipherSuite TLS_AES_128_CCM_8_SHA256 = init("TLS_AES_128_CCM_8_SHA256", 4869);
public String javaName() {
return this.javaName;
}
public String toString() {
return this.javaName;
}
public static /* synthetic */ int lambda$static$0(String str, String str2) {
int min = Math.min(str.length(), str2.length());
for (int i = 4; i < min; i++) {
char charAt = str.charAt(i);
char charAt2 = str2.charAt(i);
if (charAt != charAt2) {
return charAt < charAt2 ? -1 : 1;
}
}
int length = str.length();
int length2 = str2.length();
if (length != length2) {
return length < length2 ? -1 : 1;
}
return 0;
}
public static synchronized CipherSuite forJavaName(String str) {
CipherSuite cipherSuite;
synchronized (CipherSuite.class) {
try {
Map map = INSTANCES;
cipherSuite = (CipherSuite) map.get(str);
if (cipherSuite == null) {
cipherSuite = (CipherSuite) map.get(secondaryName(str));
if (cipherSuite == null) {
cipherSuite = new CipherSuite(str);
}
map.put(str, cipherSuite);
}
} catch (Throwable th) {
throw th;
}
}
return cipherSuite;
}
public static String secondaryName(String str) {
if (str.startsWith("TLS_")) {
return "SSL_" + str.substring(4);
}
if (!str.startsWith("SSL_")) {
return str;
}
return "TLS_" + str.substring(4);
}
public static List forJavaNames(String... strArr) {
ArrayList arrayList = new ArrayList(strArr.length);
for (String str : strArr) {
arrayList.add(forJavaName(str));
}
return Collections.unmodifiableList(arrayList);
}
public CipherSuite(String str) {
str.getClass();
this.javaName = str;
}
public static CipherSuite init(String str, int i) {
CipherSuite cipherSuite = new CipherSuite(str);
INSTANCES.put(str, cipherSuite);
return cipherSuite;
}
}

View File

@@ -0,0 +1,5 @@
package okhttp3;
/* loaded from: classes5.dex */
public interface Connection {
}

View File

@@ -0,0 +1,17 @@
package okhttp3;
import java.util.concurrent.TimeUnit;
import okhttp3.internal.connection.RealConnectionPool;
/* loaded from: classes5.dex */
public final class ConnectionPool {
public final RealConnectionPool delegate;
public ConnectionPool() {
this(5, 5L, TimeUnit.MINUTES);
}
public ConnectionPool(int i, long j, TimeUnit timeUnit) {
this.delegate = new RealConnectionPool(i, j, timeUnit);
}
}

View File

@@ -0,0 +1,224 @@
package okhttp3;
import com.ironsource.mediationsdk.logger.IronSourceError;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.net.ssl.SSLSocket;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class ConnectionSpec {
public static final CipherSuite[] APPROVED_CIPHER_SUITES;
public static final ConnectionSpec CLEARTEXT;
public static final ConnectionSpec COMPATIBLE_TLS;
public static final ConnectionSpec MODERN_TLS;
public static final CipherSuite[] RESTRICTED_CIPHER_SUITES;
public static final ConnectionSpec RESTRICTED_TLS;
public final String[] cipherSuites;
public final boolean supportsTlsExtensions;
public final boolean tls;
public final String[] tlsVersions;
public boolean isTls() {
return this.tls;
}
public boolean supportsTlsExtensions() {
return this.supportsTlsExtensions;
}
static {
CipherSuite cipherSuite = CipherSuite.TLS_AES_128_GCM_SHA256;
CipherSuite cipherSuite2 = CipherSuite.TLS_AES_256_GCM_SHA384;
CipherSuite cipherSuite3 = CipherSuite.TLS_CHACHA20_POLY1305_SHA256;
CipherSuite cipherSuite4 = CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256;
CipherSuite cipherSuite5 = CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;
CipherSuite cipherSuite6 = CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384;
CipherSuite cipherSuite7 = CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384;
CipherSuite cipherSuite8 = CipherSuite.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256;
CipherSuite cipherSuite9 = CipherSuite.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256;
CipherSuite[] cipherSuiteArr = {cipherSuite, cipherSuite2, cipherSuite3, cipherSuite4, cipherSuite5, cipherSuite6, cipherSuite7, cipherSuite8, cipherSuite9};
RESTRICTED_CIPHER_SUITES = cipherSuiteArr;
CipherSuite[] cipherSuiteArr2 = {cipherSuite, cipherSuite2, cipherSuite3, cipherSuite4, cipherSuite5, cipherSuite6, cipherSuite7, cipherSuite8, cipherSuite9, CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256, CipherSuite.TLS_RSA_WITH_AES_256_GCM_SHA384, CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA, CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA, CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA};
APPROVED_CIPHER_SUITES = cipherSuiteArr2;
Builder cipherSuites = new Builder(true).cipherSuites(cipherSuiteArr);
TlsVersion tlsVersion = TlsVersion.TLS_1_3;
TlsVersion tlsVersion2 = TlsVersion.TLS_1_2;
RESTRICTED_TLS = cipherSuites.tlsVersions(tlsVersion, tlsVersion2).supportsTlsExtensions(true).build();
MODERN_TLS = new Builder(true).cipherSuites(cipherSuiteArr2).tlsVersions(tlsVersion, tlsVersion2).supportsTlsExtensions(true).build();
COMPATIBLE_TLS = new Builder(true).cipherSuites(cipherSuiteArr2).tlsVersions(tlsVersion, tlsVersion2, TlsVersion.TLS_1_1, TlsVersion.TLS_1_0).supportsTlsExtensions(true).build();
CLEARTEXT = new Builder(false).build();
}
public ConnectionSpec(Builder builder) {
this.tls = builder.tls;
this.cipherSuites = builder.cipherSuites;
this.tlsVersions = builder.tlsVersions;
this.supportsTlsExtensions = builder.supportsTlsExtensions;
}
public List cipherSuites() {
String[] strArr = this.cipherSuites;
if (strArr != null) {
return CipherSuite.forJavaNames(strArr);
}
return null;
}
public List tlsVersions() {
String[] strArr = this.tlsVersions;
if (strArr != null) {
return TlsVersion.forJavaNames(strArr);
}
return null;
}
public void apply(SSLSocket sSLSocket, boolean z) {
ConnectionSpec supportedSpec = supportedSpec(sSLSocket, z);
String[] strArr = supportedSpec.tlsVersions;
if (strArr != null) {
sSLSocket.setEnabledProtocols(strArr);
}
String[] strArr2 = supportedSpec.cipherSuites;
if (strArr2 != null) {
sSLSocket.setEnabledCipherSuites(strArr2);
}
}
public final ConnectionSpec supportedSpec(SSLSocket sSLSocket, boolean z) {
String[] enabledCipherSuites;
String[] enabledProtocols;
if (this.cipherSuites != null) {
enabledCipherSuites = Util.intersect(CipherSuite.ORDER_BY_NAME, sSLSocket.getEnabledCipherSuites(), this.cipherSuites);
} else {
enabledCipherSuites = sSLSocket.getEnabledCipherSuites();
}
if (this.tlsVersions != null) {
enabledProtocols = Util.intersect(Util.NATURAL_ORDER, sSLSocket.getEnabledProtocols(), this.tlsVersions);
} else {
enabledProtocols = sSLSocket.getEnabledProtocols();
}
String[] supportedCipherSuites = sSLSocket.getSupportedCipherSuites();
int indexOf = Util.indexOf(CipherSuite.ORDER_BY_NAME, supportedCipherSuites, "TLS_FALLBACK_SCSV");
if (z && indexOf != -1) {
enabledCipherSuites = Util.concat(enabledCipherSuites, supportedCipherSuites[indexOf]);
}
return new Builder(this).cipherSuites(enabledCipherSuites).tlsVersions(enabledProtocols).build();
}
public boolean isCompatible(SSLSocket sSLSocket) {
if (!this.tls) {
return false;
}
String[] strArr = this.tlsVersions;
if (strArr != null && !Util.nonEmptyIntersection(Util.NATURAL_ORDER, strArr, sSLSocket.getEnabledProtocols())) {
return false;
}
String[] strArr2 = this.cipherSuites;
return strArr2 == null || Util.nonEmptyIntersection(CipherSuite.ORDER_BY_NAME, strArr2, sSLSocket.getEnabledCipherSuites());
}
public boolean equals(Object obj) {
if (!(obj instanceof ConnectionSpec)) {
return false;
}
if (obj == this) {
return true;
}
ConnectionSpec connectionSpec = (ConnectionSpec) obj;
boolean z = this.tls;
if (z != connectionSpec.tls) {
return false;
}
return !z || (Arrays.equals(this.cipherSuites, connectionSpec.cipherSuites) && Arrays.equals(this.tlsVersions, connectionSpec.tlsVersions) && this.supportsTlsExtensions == connectionSpec.supportsTlsExtensions);
}
public int hashCode() {
if (this.tls) {
return ((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + Arrays.hashCode(this.cipherSuites)) * 31) + Arrays.hashCode(this.tlsVersions)) * 31) + (!this.supportsTlsExtensions ? 1 : 0);
}
return 17;
}
public String toString() {
if (!this.tls) {
return "ConnectionSpec()";
}
return "ConnectionSpec(cipherSuites=" + Objects.toString(cipherSuites(), "[all enabled]") + ", tlsVersions=" + Objects.toString(tlsVersions(), "[all enabled]") + ", supportsTlsExtensions=" + this.supportsTlsExtensions + ")";
}
public static final class Builder {
public String[] cipherSuites;
public boolean supportsTlsExtensions;
public boolean tls;
public String[] tlsVersions;
public Builder(boolean z) {
this.tls = z;
}
public Builder(ConnectionSpec connectionSpec) {
this.tls = connectionSpec.tls;
this.cipherSuites = connectionSpec.cipherSuites;
this.tlsVersions = connectionSpec.tlsVersions;
this.supportsTlsExtensions = connectionSpec.supportsTlsExtensions;
}
public Builder cipherSuites(CipherSuite... cipherSuiteArr) {
if (!this.tls) {
throw new IllegalStateException("no cipher suites for cleartext connections");
}
String[] strArr = new String[cipherSuiteArr.length];
for (int i = 0; i < cipherSuiteArr.length; i++) {
strArr[i] = cipherSuiteArr[i].javaName;
}
return cipherSuites(strArr);
}
public Builder cipherSuites(String... strArr) {
if (!this.tls) {
throw new IllegalStateException("no cipher suites for cleartext connections");
}
if (strArr.length == 0) {
throw new IllegalArgumentException("At least one cipher suite is required");
}
this.cipherSuites = (String[]) strArr.clone();
return this;
}
public Builder tlsVersions(TlsVersion... tlsVersionArr) {
if (!this.tls) {
throw new IllegalStateException("no TLS versions for cleartext connections");
}
String[] strArr = new String[tlsVersionArr.length];
for (int i = 0; i < tlsVersionArr.length; i++) {
strArr[i] = tlsVersionArr[i].javaName;
}
return tlsVersions(strArr);
}
public Builder tlsVersions(String... strArr) {
if (!this.tls) {
throw new IllegalStateException("no TLS versions for cleartext connections");
}
if (strArr.length == 0) {
throw new IllegalArgumentException("At least one TLS version is required");
}
this.tlsVersions = (String[]) strArr.clone();
return this;
}
public Builder supportsTlsExtensions(boolean z) {
if (!this.tls) {
throw new IllegalStateException("no TLS extensions for cleartext connections");
}
this.supportsTlsExtensions = z;
return this;
}
public ConnectionSpec build() {
return new ConnectionSpec(this);
}
}
}

View File

@@ -0,0 +1,254 @@
package okhttp3;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.ironsource.nb;
import csdk.gluads.Consts;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.internal.Util;
import okhttp3.internal.http.HttpDate;
import org.apache.http.cookie.SM;
/* loaded from: classes5.dex */
public final class Cookie {
public final String domain;
public final long expiresAt;
public final boolean hostOnly;
public final boolean httpOnly;
public final String name;
public final String path;
public final boolean persistent;
public final boolean secure;
public final String value;
public static final Pattern YEAR_PATTERN = Pattern.compile("(\\d{2,4})[^\\d]*");
public static final Pattern MONTH_PATTERN = Pattern.compile("(?i)(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec).*");
public static final Pattern DAY_OF_MONTH_PATTERN = Pattern.compile("(\\d{1,2})[^\\d]*");
public static final Pattern TIME_PATTERN = Pattern.compile("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})[^\\d]*");
public String name() {
return this.name;
}
public String value() {
return this.value;
}
public Cookie(String str, String str2, long j, String str3, String str4, boolean z, boolean z2, boolean z3, boolean z4) {
this.name = str;
this.value = str2;
this.expiresAt = j;
this.domain = str3;
this.path = str4;
this.secure = z;
this.httpOnly = z2;
this.hostOnly = z3;
this.persistent = z4;
}
public static boolean domainMatch(String str, String str2) {
if (str.equals(str2)) {
return true;
}
return str.endsWith(str2) && str.charAt((str.length() - str2.length()) - 1) == '.' && !Util.verifyAsIpAddress(str);
}
public static Cookie parse(HttpUrl httpUrl, String str) {
return parse(System.currentTimeMillis(), httpUrl, str);
}
/* JADX WARN: Removed duplicated region for block: B:54:0x00ee */
/* JADX WARN: Removed duplicated region for block: B:69:0x0129 */
/* JADX WARN: Removed duplicated region for block: B:71:0x00f1 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static okhttp3.Cookie parse(long r23, okhttp3.HttpUrl r25, java.lang.String r26) {
/*
Method dump skipped, instructions count: 310
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.Cookie.parse(long, okhttp3.HttpUrl, java.lang.String):okhttp3.Cookie");
}
public static long parseExpires(String str, int i, int i2) {
int dateCharacterOffset = dateCharacterOffset(str, i, i2, false);
Matcher matcher = TIME_PATTERN.matcher(str);
int i3 = -1;
int i4 = -1;
int i5 = -1;
int i6 = -1;
int i7 = -1;
int i8 = -1;
while (dateCharacterOffset < i2) {
int dateCharacterOffset2 = dateCharacterOffset(str, dateCharacterOffset + 1, i2, true);
matcher.region(dateCharacterOffset, dateCharacterOffset2);
if (i4 == -1 && matcher.usePattern(TIME_PATTERN).matches()) {
i4 = Integer.parseInt(matcher.group(1));
i7 = Integer.parseInt(matcher.group(2));
i8 = Integer.parseInt(matcher.group(3));
} else if (i5 == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) {
i5 = Integer.parseInt(matcher.group(1));
} else {
if (i6 == -1) {
Pattern pattern = MONTH_PATTERN;
if (matcher.usePattern(pattern).matches()) {
i6 = pattern.pattern().indexOf(matcher.group(1).toLowerCase(Locale.US)) / 4;
}
}
if (i3 == -1 && matcher.usePattern(YEAR_PATTERN).matches()) {
i3 = Integer.parseInt(matcher.group(1));
}
}
dateCharacterOffset = dateCharacterOffset(str, dateCharacterOffset2 + 1, i2, false);
}
if (i3 >= 70 && i3 <= 99) {
i3 += 1900;
}
if (i3 >= 0 && i3 <= 69) {
i3 += 2000;
}
if (i3 < 1601) {
throw new IllegalArgumentException();
}
if (i6 == -1) {
throw new IllegalArgumentException();
}
if (i5 < 1 || i5 > 31) {
throw new IllegalArgumentException();
}
if (i4 < 0 || i4 > 23) {
throw new IllegalArgumentException();
}
if (i7 < 0 || i7 > 59) {
throw new IllegalArgumentException();
}
if (i8 < 0 || i8 > 59) {
throw new IllegalArgumentException();
}
GregorianCalendar gregorianCalendar = new GregorianCalendar(Util.UTC);
gregorianCalendar.setLenient(false);
gregorianCalendar.set(1, i3);
gregorianCalendar.set(2, i6 - 1);
gregorianCalendar.set(5, i5);
gregorianCalendar.set(11, i4);
gregorianCalendar.set(12, i7);
gregorianCalendar.set(13, i8);
gregorianCalendar.set(14, 0);
return gregorianCalendar.getTimeInMillis();
}
public static int dateCharacterOffset(String str, int i, int i2, boolean z) {
while (i < i2) {
char charAt = str.charAt(i);
if (((charAt < ' ' && charAt != '\t') || charAt >= 127 || (charAt >= '0' && charAt <= '9') || ((charAt >= 'a' && charAt <= 'z') || ((charAt >= 'A' && charAt <= 'Z') || charAt == ':'))) == (!z)) {
return i;
}
i++;
}
return i2;
}
public static long parseMaxAge(String str) {
try {
long parseLong = Long.parseLong(str);
if (parseLong <= 0) {
return Long.MIN_VALUE;
}
return parseLong;
} catch (NumberFormatException e) {
if (str.matches("-?\\d+")) {
return str.startsWith("-") ? Long.MIN_VALUE : Long.MAX_VALUE;
}
throw e;
}
}
public static String parseDomain(String str) {
if (str.endsWith(Consts.STRING_PERIOD)) {
throw new IllegalArgumentException();
}
if (str.startsWith(Consts.STRING_PERIOD)) {
str = str.substring(1);
}
String canonicalizeHost = Util.canonicalizeHost(str);
if (canonicalizeHost != null) {
return canonicalizeHost;
}
throw new IllegalArgumentException();
}
public static List parseAll(HttpUrl httpUrl, Headers headers) {
List values = headers.values(SM.SET_COOKIE);
int size = values.size();
ArrayList arrayList = null;
for (int i = 0; i < size; i++) {
Cookie parse = parse(httpUrl, (String) values.get(i));
if (parse != null) {
if (arrayList == null) {
arrayList = new ArrayList();
}
arrayList.add(parse);
}
}
if (arrayList != null) {
return Collections.unmodifiableList(arrayList);
}
return Collections.emptyList();
}
public String toString() {
return toString(false);
}
public String toString(boolean z) {
StringBuilder sb = new StringBuilder();
sb.append(this.name);
sb.append(nb.T);
sb.append(this.value);
if (this.persistent) {
if (this.expiresAt == Long.MIN_VALUE) {
sb.append("; max-age=0");
} else {
sb.append("; expires=");
sb.append(HttpDate.format(new Date(this.expiresAt)));
}
}
if (!this.hostOnly) {
sb.append("; domain=");
if (z) {
sb.append(Consts.STRING_PERIOD);
}
sb.append(this.domain);
}
sb.append("; path=");
sb.append(this.path);
if (this.secure) {
sb.append("; secure");
}
if (this.httpOnly) {
sb.append("; httponly");
}
return sb.toString();
}
public boolean equals(Object obj) {
if (!(obj instanceof Cookie)) {
return false;
}
Cookie cookie = (Cookie) obj;
return cookie.name.equals(this.name) && cookie.value.equals(this.value) && cookie.domain.equals(this.domain) && cookie.path.equals(this.path) && cookie.expiresAt == this.expiresAt && cookie.secure == this.secure && cookie.httpOnly == this.httpOnly && cookie.persistent == this.persistent && cookie.hostOnly == this.hostOnly;
}
public int hashCode() {
int hashCode = (((((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.name.hashCode()) * 31) + this.value.hashCode()) * 31) + this.domain.hashCode()) * 31) + this.path.hashCode()) * 31;
long j = this.expiresAt;
return ((((((((hashCode + ((int) (j ^ (j >>> 32)))) * 31) + (!this.secure ? 1 : 0)) * 31) + (!this.httpOnly ? 1 : 0)) * 31) + (!this.persistent ? 1 : 0)) * 31) + (!this.hostOnly ? 1 : 0);
}
}

View File

@@ -0,0 +1,22 @@
package okhttp3;
import java.util.Collections;
import java.util.List;
/* loaded from: classes5.dex */
public interface CookieJar {
public static final CookieJar NO_COOKIES = new CookieJar() { // from class: okhttp3.CookieJar.1
@Override // okhttp3.CookieJar
public void saveFromResponse(HttpUrl httpUrl, List list) {
}
@Override // okhttp3.CookieJar
public List loadForRequest(HttpUrl httpUrl) {
return Collections.emptyList();
}
};
List loadForRequest(HttpUrl httpUrl);
void saveFromResponse(HttpUrl httpUrl, List list);
}

View File

@@ -0,0 +1,125 @@
package okhttp3;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import okhttp3.RealCall;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class Dispatcher {
public ExecutorService executorService;
public Runnable idleCallback;
public int maxRequests = 64;
public int maxRequestsPerHost = 5;
public final Deque readyAsyncCalls = new ArrayDeque();
public final Deque runningAsyncCalls = new ArrayDeque();
public final Deque runningSyncCalls = new ArrayDeque();
public synchronized ExecutorService executorService() {
try {
if (this.executorService == null) {
this.executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), Util.threadFactory("OkHttp Dispatcher", false));
}
} catch (Throwable th) {
throw th;
}
return this.executorService;
}
public void enqueue(RealCall.AsyncCall asyncCall) {
RealCall.AsyncCall findExistingCallWithHost;
synchronized (this) {
try {
this.readyAsyncCalls.add(asyncCall);
if (!asyncCall.get().forWebSocket && (findExistingCallWithHost = findExistingCallWithHost(asyncCall.host())) != null) {
asyncCall.reuseCallsPerHostFrom(findExistingCallWithHost);
}
} catch (Throwable th) {
throw th;
}
}
promoteAndExecute();
}
public final RealCall.AsyncCall findExistingCallWithHost(String str) {
for (RealCall.AsyncCall asyncCall : this.runningAsyncCalls) {
if (asyncCall.host().equals(str)) {
return asyncCall;
}
}
for (RealCall.AsyncCall asyncCall2 : this.readyAsyncCalls) {
if (asyncCall2.host().equals(str)) {
return asyncCall2;
}
}
return null;
}
public final boolean promoteAndExecute() {
int i;
boolean z;
ArrayList arrayList = new ArrayList();
synchronized (this) {
try {
Iterator it = this.readyAsyncCalls.iterator();
while (it.hasNext()) {
RealCall.AsyncCall asyncCall = (RealCall.AsyncCall) it.next();
if (this.runningAsyncCalls.size() >= this.maxRequests) {
break;
}
if (asyncCall.callsPerHost().get() < this.maxRequestsPerHost) {
it.remove();
asyncCall.callsPerHost().incrementAndGet();
arrayList.add(asyncCall);
this.runningAsyncCalls.add(asyncCall);
}
}
z = runningCallsCount() > 0;
} catch (Throwable th) {
throw th;
}
}
int size = arrayList.size();
for (i = 0; i < size; i++) {
((RealCall.AsyncCall) arrayList.get(i)).executeOn(executorService());
}
return z;
}
public synchronized void executed(RealCall realCall) {
this.runningSyncCalls.add(realCall);
}
public void finished(RealCall.AsyncCall asyncCall) {
asyncCall.callsPerHost().decrementAndGet();
finished(this.runningAsyncCalls, asyncCall);
}
public void finished(RealCall realCall) {
finished(this.runningSyncCalls, realCall);
}
public final void finished(Deque deque, Object obj) {
Runnable runnable;
synchronized (this) {
if (!deque.remove(obj)) {
throw new AssertionError("Call wasn't in-flight!");
}
runnable = this.idleCallback;
}
if (promoteAndExecute() || runnable == null) {
return;
}
runnable.run();
}
public synchronized int runningCallsCount() {
return this.runningAsyncCalls.size() + this.runningSyncCalls.size();
}
}

View File

@@ -0,0 +1,33 @@
package okhttp3;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
/* loaded from: classes5.dex */
public interface Dns {
public static final Dns SYSTEM = new Dns() { // from class: okhttp3.Dns$$ExternalSyntheticLambda0
@Override // okhttp3.Dns
public final List lookup(String str) {
List lambda$static$0;
lambda$static$0 = Dns.lambda$static$0(str);
return lambda$static$0;
}
};
List lookup(String str);
static /* synthetic */ List lambda$static$0(String str) {
if (str == null) {
throw new UnknownHostException("hostname == null");
}
try {
return Arrays.asList(InetAddress.getAllByName(str));
} catch (NullPointerException e) {
UnknownHostException unknownHostException = new UnknownHostException("Broken system behaviour for dns lookup of " + str);
unknownHostException.initCause(e);
throw unknownHostException;
}
}
}

View File

@@ -0,0 +1,97 @@
package okhttp3;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.List;
/* loaded from: classes5.dex */
public abstract class EventListener {
public static final EventListener NONE = new EventListener() { // from class: okhttp3.EventListener.1
};
public interface Factory {
EventListener create(Call call);
}
public static /* synthetic */ EventListener lambda$factory$0(EventListener eventListener, Call call) {
return eventListener;
}
public void callEnd(Call call) {
}
public void callFailed(Call call, IOException iOException) {
}
public void callStart(Call call) {
}
public void connectEnd(Call call, InetSocketAddress inetSocketAddress, Proxy proxy, Protocol protocol) {
}
public void connectFailed(Call call, InetSocketAddress inetSocketAddress, Proxy proxy, Protocol protocol, IOException iOException) {
}
public void connectStart(Call call, InetSocketAddress inetSocketAddress, Proxy proxy) {
}
public void connectionAcquired(Call call, Connection connection) {
}
public void connectionReleased(Call call, Connection connection) {
}
public void dnsEnd(Call call, String str, List list) {
}
public void dnsStart(Call call, String str) {
}
public void requestBodyEnd(Call call, long j) {
}
public void requestBodyStart(Call call) {
}
public void requestFailed(Call call, IOException iOException) {
}
public void requestHeadersEnd(Call call, Request request) {
}
public void requestHeadersStart(Call call) {
}
public void responseBodyEnd(Call call, long j) {
}
public void responseBodyStart(Call call) {
}
public void responseFailed(Call call, IOException iOException) {
}
public void responseHeadersEnd(Call call, Response response) {
}
public void responseHeadersStart(Call call) {
}
public void secureConnectEnd(Call call, Handshake handshake) {
}
public void secureConnectStart(Call call) {
}
public static Factory factory(final EventListener eventListener) {
return new Factory() { // from class: okhttp3.EventListener$$ExternalSyntheticLambda0
@Override // okhttp3.EventListener.Factory
public final EventListener create(Call call) {
EventListener lambda$factory$0;
lambda$factory$0 = EventListener.lambda$factory$0(EventListener.this, call);
return lambda$factory$0;
}
};
}
}

View File

@@ -0,0 +1,123 @@
package okhttp3;
import com.ironsource.mediationsdk.logger.IronSourceError;
import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class Handshake {
public final CipherSuite cipherSuite;
public final List localCertificates;
public final List peerCertificates;
public final TlsVersion tlsVersion;
public CipherSuite cipherSuite() {
return this.cipherSuite;
}
public List localCertificates() {
return this.localCertificates;
}
public List peerCertificates() {
return this.peerCertificates;
}
public TlsVersion tlsVersion() {
return this.tlsVersion;
}
public Handshake(TlsVersion tlsVersion, CipherSuite cipherSuite, List list, List list2) {
this.tlsVersion = tlsVersion;
this.cipherSuite = cipherSuite;
this.peerCertificates = list;
this.localCertificates = list2;
}
public static Handshake get(SSLSession sSLSession) {
Certificate[] certificateArr;
List emptyList;
List emptyList2;
String cipherSuite = sSLSession.getCipherSuite();
if (cipherSuite == null) {
throw new IllegalStateException("cipherSuite == null");
}
if ("SSL_NULL_WITH_NULL_NULL".equals(cipherSuite)) {
throw new IOException("cipherSuite == SSL_NULL_WITH_NULL_NULL");
}
CipherSuite forJavaName = CipherSuite.forJavaName(cipherSuite);
String protocol = sSLSession.getProtocol();
if (protocol == null) {
throw new IllegalStateException("tlsVersion == null");
}
if ("NONE".equals(protocol)) {
throw new IOException("tlsVersion == NONE");
}
TlsVersion forJavaName2 = TlsVersion.forJavaName(protocol);
try {
certificateArr = sSLSession.getPeerCertificates();
} catch (SSLPeerUnverifiedException unused) {
certificateArr = null;
}
if (certificateArr != null) {
emptyList = Util.immutableList(certificateArr);
} else {
emptyList = Collections.emptyList();
}
Certificate[] localCertificates = sSLSession.getLocalCertificates();
if (localCertificates != null) {
emptyList2 = Util.immutableList(localCertificates);
} else {
emptyList2 = Collections.emptyList();
}
return new Handshake(forJavaName2, forJavaName, emptyList, emptyList2);
}
public static Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite, List list, List list2) {
if (tlsVersion == null) {
throw new NullPointerException("tlsVersion == null");
}
if (cipherSuite == null) {
throw new NullPointerException("cipherSuite == null");
}
return new Handshake(tlsVersion, cipherSuite, Util.immutableList(list), Util.immutableList(list2));
}
public boolean equals(Object obj) {
if (!(obj instanceof Handshake)) {
return false;
}
Handshake handshake = (Handshake) obj;
return this.tlsVersion.equals(handshake.tlsVersion) && this.cipherSuite.equals(handshake.cipherSuite) && this.peerCertificates.equals(handshake.peerCertificates) && this.localCertificates.equals(handshake.localCertificates);
}
public int hashCode() {
return ((((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.tlsVersion.hashCode()) * 31) + this.cipherSuite.hashCode()) * 31) + this.peerCertificates.hashCode()) * 31) + this.localCertificates.hashCode();
}
public String toString() {
return "Handshake{tlsVersion=" + this.tlsVersion + " cipherSuite=" + this.cipherSuite + " peerCertificates=" + names(this.peerCertificates) + " localCertificates=" + names(this.localCertificates) + '}';
}
public final List names(List list) {
ArrayList arrayList = new ArrayList();
Iterator it = list.iterator();
while (it.hasNext()) {
Certificate certificate = (Certificate) it.next();
if (certificate instanceof X509Certificate) {
arrayList.add(String.valueOf(((X509Certificate) certificate).getSubjectDN()));
} else {
arrayList.add(certificate.getType());
}
}
return arrayList;
}
}

View File

@@ -0,0 +1,222 @@
package okhttp3;
import com.facebook.internal.security.CertificateUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class Headers {
public final String[] namesAndValues;
public Headers(Builder builder) {
List list = builder.namesAndValues;
this.namesAndValues = (String[]) list.toArray(new String[list.size()]);
}
public Headers(String[] strArr) {
this.namesAndValues = strArr;
}
public String get(String str) {
return get(this.namesAndValues, str);
}
public int size() {
return this.namesAndValues.length / 2;
}
public String name(int i) {
return this.namesAndValues[i * 2];
}
public String value(int i) {
return this.namesAndValues[(i * 2) + 1];
}
public List values(String str) {
int size = size();
ArrayList arrayList = null;
for (int i = 0; i < size; i++) {
if (str.equalsIgnoreCase(name(i))) {
if (arrayList == null) {
arrayList = new ArrayList(2);
}
arrayList.add(value(i));
}
}
if (arrayList != null) {
return Collections.unmodifiableList(arrayList);
}
return Collections.emptyList();
}
public Builder newBuilder() {
Builder builder = new Builder();
Collections.addAll(builder.namesAndValues, this.namesAndValues);
return builder;
}
public boolean equals(Object obj) {
return (obj instanceof Headers) && Arrays.equals(((Headers) obj).namesAndValues, this.namesAndValues);
}
public int hashCode() {
return Arrays.hashCode(this.namesAndValues);
}
public String toString() {
StringBuilder sb = new StringBuilder();
int size = size();
for (int i = 0; i < size; i++) {
sb.append(name(i));
sb.append(": ");
sb.append(value(i));
sb.append("\n");
}
return sb.toString();
}
public Map toMultimap() {
TreeMap treeMap = new TreeMap(String.CASE_INSENSITIVE_ORDER);
int size = size();
for (int i = 0; i < size; i++) {
String lowerCase = name(i).toLowerCase(Locale.US);
List list = (List) treeMap.get(lowerCase);
if (list == null) {
list = new ArrayList(2);
treeMap.put(lowerCase, list);
}
list.add(value(i));
}
return treeMap;
}
public static String get(String[] strArr, String str) {
for (int length = strArr.length - 2; length >= 0; length -= 2) {
if (str.equalsIgnoreCase(strArr[length])) {
return strArr[length + 1];
}
}
return null;
}
public static Headers of(String... strArr) {
if (strArr == null) {
throw new NullPointerException("namesAndValues == null");
}
if (strArr.length % 2 != 0) {
throw new IllegalArgumentException("Expected alternating header names and values");
}
String[] strArr2 = (String[]) strArr.clone();
for (int i = 0; i < strArr2.length; i++) {
String str = strArr2[i];
if (str == null) {
throw new IllegalArgumentException("Headers cannot be null");
}
strArr2[i] = str.trim();
}
for (int i2 = 0; i2 < strArr2.length; i2 += 2) {
String str2 = strArr2[i2];
String str3 = strArr2[i2 + 1];
checkName(str2);
checkValue(str3, str2);
}
return new Headers(strArr2);
}
public static void checkName(String str) {
if (str == null) {
throw new NullPointerException("name == null");
}
if (str.isEmpty()) {
throw new IllegalArgumentException("name is empty");
}
int length = str.length();
for (int i = 0; i < length; i++) {
char charAt = str.charAt(i);
if (charAt <= ' ' || charAt >= 127) {
throw new IllegalArgumentException(Util.format("Unexpected char %#04x at %d in header name: %s", Integer.valueOf(charAt), Integer.valueOf(i), str));
}
}
}
public static void checkValue(String str, String str2) {
if (str == null) {
throw new NullPointerException("value for name " + str2 + " == null");
}
int length = str.length();
for (int i = 0; i < length; i++) {
char charAt = str.charAt(i);
if ((charAt <= 31 && charAt != '\t') || charAt >= 127) {
throw new IllegalArgumentException(Util.format("Unexpected char %#04x at %d in %s value: %s", Integer.valueOf(charAt), Integer.valueOf(i), str2, str));
}
}
}
public static final class Builder {
public final List namesAndValues = new ArrayList(20);
public Builder addLenient(String str) {
int indexOf = str.indexOf(CertificateUtil.DELIMITER, 1);
if (indexOf != -1) {
return addLenient(str.substring(0, indexOf), str.substring(indexOf + 1));
}
if (str.startsWith(CertificateUtil.DELIMITER)) {
return addLenient("", str.substring(1));
}
return addLenient("", str);
}
public Builder add(String str, String str2) {
Headers.checkName(str);
Headers.checkValue(str2, str);
return addLenient(str, str2);
}
public Builder addLenient(String str, String str2) {
this.namesAndValues.add(str);
this.namesAndValues.add(str2.trim());
return this;
}
public Builder removeAll(String str) {
int i = 0;
while (i < this.namesAndValues.size()) {
if (str.equalsIgnoreCase((String) this.namesAndValues.get(i))) {
this.namesAndValues.remove(i);
this.namesAndValues.remove(i);
i -= 2;
}
i += 2;
}
return this;
}
public Builder set(String str, String str2) {
Headers.checkName(str);
Headers.checkValue(str2, str);
removeAll(str);
addLenient(str, str2);
return this;
}
public String get(String str) {
for (int size = this.namesAndValues.size() - 2; size >= 0; size -= 2) {
if (str.equalsIgnoreCase((String) this.namesAndValues.get(size))) {
return (String) this.namesAndValues.get(size + 1);
}
}
return null;
}
public Headers build() {
return new Headers(this);
}
}
}

View File

@@ -0,0 +1,761 @@
package okhttp3;
import com.applovin.exoplayer2.common.base.Ascii;
import com.ironsource.nb;
import csdk.gluads.Consts;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import okhttp3.internal.Util;
import okio.Buffer;
/* loaded from: classes5.dex */
public final class HttpUrl {
public static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public final String fragment;
public final String host;
public final String password;
public final List pathSegments;
public final int port;
public final List queryNamesAndValues;
public final String scheme;
public final String url;
public final String username;
public String host() {
return this.host;
}
public int port() {
return this.port;
}
public String scheme() {
return this.scheme;
}
public String toString() {
return this.url;
}
public HttpUrl(Builder builder) {
this.scheme = builder.scheme;
this.username = percentDecode(builder.encodedUsername, false);
this.password = percentDecode(builder.encodedPassword, false);
this.host = builder.host;
this.port = builder.effectivePort();
this.pathSegments = percentDecode(builder.encodedPathSegments, false);
List list = builder.encodedQueryNamesAndValues;
this.queryNamesAndValues = list != null ? percentDecode(list, true) : null;
String str = builder.encodedFragment;
this.fragment = str != null ? percentDecode(str, false) : null;
this.url = builder.toString();
}
public URL url() {
try {
return new URL(this.url);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
public URI uri() {
String builder = newBuilder().reencodeForUri().toString();
try {
return new URI(builder);
} catch (URISyntaxException e) {
try {
return URI.create(builder.replaceAll("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]", ""));
} catch (Exception unused) {
throw new RuntimeException(e);
}
}
}
public boolean isHttps() {
return this.scheme.equals("https");
}
public String encodedUsername() {
if (this.username.isEmpty()) {
return "";
}
int length = this.scheme.length() + 3;
String str = this.url;
return this.url.substring(length, Util.delimiterOffset(str, length, str.length(), ":@"));
}
public String encodedPassword() {
if (this.password.isEmpty()) {
return "";
}
return this.url.substring(this.url.indexOf(58, this.scheme.length() + 3) + 1, this.url.indexOf(64));
}
public static int defaultPort(String str) {
if (str.equals("http")) {
return 80;
}
return str.equals("https") ? 443 : -1;
}
public String encodedPath() {
int indexOf = this.url.indexOf(47, this.scheme.length() + 3);
String str = this.url;
return this.url.substring(indexOf, Util.delimiterOffset(str, indexOf, str.length(), "?#"));
}
public static void pathSegmentsToString(StringBuilder sb, List list) {
int size = list.size();
for (int i = 0; i < size; i++) {
sb.append('/');
sb.append((String) list.get(i));
}
}
public List encodedPathSegments() {
int indexOf = this.url.indexOf(47, this.scheme.length() + 3);
String str = this.url;
int delimiterOffset = Util.delimiterOffset(str, indexOf, str.length(), "?#");
ArrayList arrayList = new ArrayList();
while (indexOf < delimiterOffset) {
int i = indexOf + 1;
int delimiterOffset2 = Util.delimiterOffset(this.url, i, delimiterOffset, '/');
arrayList.add(this.url.substring(i, delimiterOffset2));
indexOf = delimiterOffset2;
}
return arrayList;
}
public String encodedQuery() {
if (this.queryNamesAndValues == null) {
return null;
}
int indexOf = this.url.indexOf(63) + 1;
String str = this.url;
return this.url.substring(indexOf, Util.delimiterOffset(str, indexOf, str.length(), '#'));
}
public static void namesAndValuesToQueryString(StringBuilder sb, List list) {
int size = list.size();
for (int i = 0; i < size; i += 2) {
String str = (String) list.get(i);
String str2 = (String) list.get(i + 1);
if (i > 0) {
sb.append('&');
}
sb.append(str);
if (str2 != null) {
sb.append(nb.T);
sb.append(str2);
}
}
}
public static List queryStringToNamesAndValues(String str) {
ArrayList arrayList = new ArrayList();
int i = 0;
while (i <= str.length()) {
int indexOf = str.indexOf(38, i);
if (indexOf == -1) {
indexOf = str.length();
}
int indexOf2 = str.indexOf(61, i);
if (indexOf2 == -1 || indexOf2 > indexOf) {
arrayList.add(str.substring(i, indexOf));
arrayList.add(null);
} else {
arrayList.add(str.substring(i, indexOf2));
arrayList.add(str.substring(indexOf2 + 1, indexOf));
}
i = indexOf + 1;
}
return arrayList;
}
public String query() {
if (this.queryNamesAndValues == null) {
return null;
}
StringBuilder sb = new StringBuilder();
namesAndValuesToQueryString(sb, this.queryNamesAndValues);
return sb.toString();
}
public String encodedFragment() {
if (this.fragment == null) {
return null;
}
return this.url.substring(this.url.indexOf(35) + 1);
}
public String redact() {
return newBuilder("/...").username("").password("").build().toString();
}
public HttpUrl resolve(String str) {
Builder newBuilder = newBuilder(str);
if (newBuilder != null) {
return newBuilder.build();
}
return null;
}
public Builder newBuilder() {
Builder builder = new Builder();
builder.scheme = this.scheme;
builder.encodedUsername = encodedUsername();
builder.encodedPassword = encodedPassword();
builder.host = this.host;
builder.port = this.port != defaultPort(this.scheme) ? this.port : -1;
builder.encodedPathSegments.clear();
builder.encodedPathSegments.addAll(encodedPathSegments());
builder.encodedQuery(encodedQuery());
builder.encodedFragment = encodedFragment();
return builder;
}
public Builder newBuilder(String str) {
try {
return new Builder().parse(this, str);
} catch (IllegalArgumentException unused) {
return null;
}
}
public static HttpUrl parse(String str) {
try {
return get(str);
} catch (IllegalArgumentException unused) {
return null;
}
}
public static HttpUrl get(String str) {
return new Builder().parse(null, str).build();
}
public boolean equals(Object obj) {
return (obj instanceof HttpUrl) && ((HttpUrl) obj).url.equals(this.url);
}
public int hashCode() {
return this.url.hashCode();
}
public static final class Builder {
public String encodedFragment;
public final List encodedPathSegments;
public List encodedQueryNamesAndValues;
public String host;
public String scheme;
public String encodedUsername = "";
public String encodedPassword = "";
public int port = -1;
public Builder() {
ArrayList arrayList = new ArrayList();
this.encodedPathSegments = arrayList;
arrayList.add("");
}
public Builder scheme(String str) {
if (str == null) {
throw new NullPointerException("scheme == null");
}
if (str.equalsIgnoreCase("http")) {
this.scheme = "http";
} else {
if (!str.equalsIgnoreCase("https")) {
throw new IllegalArgumentException("unexpected scheme: " + str);
}
this.scheme = "https";
}
return this;
}
public Builder username(String str) {
if (str == null) {
throw new NullPointerException("username == null");
}
this.encodedUsername = HttpUrl.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#", false, false, false, true);
return this;
}
public Builder password(String str) {
if (str == null) {
throw new NullPointerException("password == null");
}
this.encodedPassword = HttpUrl.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#", false, false, false, true);
return this;
}
public Builder host(String str) {
if (str == null) {
throw new NullPointerException("host == null");
}
String canonicalizeHost = canonicalizeHost(str, 0, str.length());
if (canonicalizeHost != null) {
this.host = canonicalizeHost;
return this;
}
throw new IllegalArgumentException("unexpected host: " + str);
}
public Builder port(int i) {
if (i > 0 && i <= 65535) {
this.port = i;
return this;
}
throw new IllegalArgumentException("unexpected port: " + i);
}
public int effectivePort() {
int i = this.port;
return i != -1 ? i : HttpUrl.defaultPort(this.scheme);
}
public Builder query(String str) {
this.encodedQueryNamesAndValues = str != null ? HttpUrl.queryStringToNamesAndValues(HttpUrl.canonicalize(str, " \"'<>#", false, false, true, true)) : null;
return this;
}
public Builder encodedQuery(String str) {
this.encodedQueryNamesAndValues = str != null ? HttpUrl.queryStringToNamesAndValues(HttpUrl.canonicalize(str, " \"'<>#", true, false, true, true)) : null;
return this;
}
public Builder fragment(String str) {
this.encodedFragment = str != null ? HttpUrl.canonicalize(str, "", false, false, false, false) : null;
return this;
}
public Builder reencodeForUri() {
int size = this.encodedPathSegments.size();
for (int i = 0; i < size; i++) {
this.encodedPathSegments.set(i, HttpUrl.canonicalize((String) this.encodedPathSegments.get(i), "[]", true, true, false, true));
}
List list = this.encodedQueryNamesAndValues;
if (list != null) {
int size2 = list.size();
for (int i2 = 0; i2 < size2; i2++) {
String str = (String) this.encodedQueryNamesAndValues.get(i2);
if (str != null) {
this.encodedQueryNamesAndValues.set(i2, HttpUrl.canonicalize(str, "\\^`{|}", true, true, true, true));
}
}
}
String str2 = this.encodedFragment;
if (str2 != null) {
this.encodedFragment = HttpUrl.canonicalize(str2, " \"#<>\\^`{|}", true, true, false, false);
}
return this;
}
public HttpUrl build() {
if (this.scheme == null) {
throw new IllegalStateException("scheme == null");
}
if (this.host == null) {
throw new IllegalStateException("host == null");
}
return new HttpUrl(this);
}
public String toString() {
StringBuilder sb = new StringBuilder();
String str = this.scheme;
if (str != null) {
sb.append(str);
sb.append("://");
} else {
sb.append("//");
}
if (!this.encodedUsername.isEmpty() || !this.encodedPassword.isEmpty()) {
sb.append(this.encodedUsername);
if (!this.encodedPassword.isEmpty()) {
sb.append(':');
sb.append(this.encodedPassword);
}
sb.append('@');
}
String str2 = this.host;
if (str2 != null) {
if (str2.indexOf(58) != -1) {
sb.append('[');
sb.append(this.host);
sb.append(']');
} else {
sb.append(this.host);
}
}
if (this.port != -1 || this.scheme != null) {
int effectivePort = effectivePort();
String str3 = this.scheme;
if (str3 == null || effectivePort != HttpUrl.defaultPort(str3)) {
sb.append(':');
sb.append(effectivePort);
}
}
HttpUrl.pathSegmentsToString(sb, this.encodedPathSegments);
if (this.encodedQueryNamesAndValues != null) {
sb.append('?');
HttpUrl.namesAndValuesToQueryString(sb, this.encodedQueryNamesAndValues);
}
if (this.encodedFragment != null) {
sb.append('#');
sb.append(this.encodedFragment);
}
return sb.toString();
}
public Builder parse(HttpUrl httpUrl, String str) {
int delimiterOffset;
int i;
int skipLeadingAsciiWhitespace = Util.skipLeadingAsciiWhitespace(str, 0, str.length());
int skipTrailingAsciiWhitespace = Util.skipTrailingAsciiWhitespace(str, skipLeadingAsciiWhitespace, str.length());
int schemeDelimiterOffset = schemeDelimiterOffset(str, skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace);
if (schemeDelimiterOffset != -1) {
if (str.regionMatches(true, skipLeadingAsciiWhitespace, "https:", 0, 6)) {
this.scheme = "https";
skipLeadingAsciiWhitespace += 6;
} else {
if (!str.regionMatches(true, skipLeadingAsciiWhitespace, "http:", 0, 5)) {
throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but was '" + str.substring(0, schemeDelimiterOffset) + "'");
}
this.scheme = "http";
skipLeadingAsciiWhitespace += 5;
}
} else if (httpUrl != null) {
this.scheme = httpUrl.scheme;
} else {
throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but no colon was found");
}
int slashCount = slashCount(str, skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace);
char c = '?';
char c2 = '#';
if (slashCount >= 2 || httpUrl == null || !httpUrl.scheme.equals(this.scheme)) {
boolean z = false;
boolean z2 = false;
int i2 = skipLeadingAsciiWhitespace + slashCount;
while (true) {
delimiterOffset = Util.delimiterOffset(str, i2, skipTrailingAsciiWhitespace, "@/\\?#");
char charAt = delimiterOffset != skipTrailingAsciiWhitespace ? str.charAt(delimiterOffset) : (char) 65535;
if (charAt == 65535 || charAt == c2 || charAt == '/' || charAt == '\\' || charAt == c) {
break;
}
if (charAt == '@') {
if (!z) {
int delimiterOffset2 = Util.delimiterOffset(str, i2, delimiterOffset, ':');
i = delimiterOffset;
String canonicalize = HttpUrl.canonicalize(str, i2, delimiterOffset2, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
if (z2) {
canonicalize = this.encodedUsername + "%40" + canonicalize;
}
this.encodedUsername = canonicalize;
if (delimiterOffset2 != i) {
this.encodedPassword = HttpUrl.canonicalize(str, delimiterOffset2 + 1, i, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
z = true;
}
z2 = true;
} else {
i = delimiterOffset;
this.encodedPassword += "%40" + HttpUrl.canonicalize(str, i2, i, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
}
i2 = i + 1;
}
c = '?';
c2 = '#';
}
int portColonOffset = portColonOffset(str, i2, delimiterOffset);
int i3 = portColonOffset + 1;
if (i3 < delimiterOffset) {
this.host = canonicalizeHost(str, i2, portColonOffset);
int parsePort = parsePort(str, i3, delimiterOffset);
this.port = parsePort;
if (parsePort == -1) {
throw new IllegalArgumentException("Invalid URL port: \"" + str.substring(i3, delimiterOffset) + '\"');
}
} else {
this.host = canonicalizeHost(str, i2, portColonOffset);
this.port = HttpUrl.defaultPort(this.scheme);
}
if (this.host == null) {
throw new IllegalArgumentException("Invalid URL host: \"" + str.substring(i2, portColonOffset) + '\"');
}
skipLeadingAsciiWhitespace = delimiterOffset;
} else {
this.encodedUsername = httpUrl.encodedUsername();
this.encodedPassword = httpUrl.encodedPassword();
this.host = httpUrl.host;
this.port = httpUrl.port;
this.encodedPathSegments.clear();
this.encodedPathSegments.addAll(httpUrl.encodedPathSegments());
if (skipLeadingAsciiWhitespace == skipTrailingAsciiWhitespace || str.charAt(skipLeadingAsciiWhitespace) == '#') {
encodedQuery(httpUrl.encodedQuery());
}
}
int delimiterOffset3 = Util.delimiterOffset(str, skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace, "?#");
resolvePath(str, skipLeadingAsciiWhitespace, delimiterOffset3);
if (delimiterOffset3 < skipTrailingAsciiWhitespace && str.charAt(delimiterOffset3) == '?') {
int delimiterOffset4 = Util.delimiterOffset(str, delimiterOffset3, skipTrailingAsciiWhitespace, '#');
this.encodedQueryNamesAndValues = HttpUrl.queryStringToNamesAndValues(HttpUrl.canonicalize(str, delimiterOffset3 + 1, delimiterOffset4, " \"'<>#", true, false, true, true, null));
delimiterOffset3 = delimiterOffset4;
}
if (delimiterOffset3 < skipTrailingAsciiWhitespace && str.charAt(delimiterOffset3) == '#') {
this.encodedFragment = HttpUrl.canonicalize(str, 1 + delimiterOffset3, skipTrailingAsciiWhitespace, "", true, false, false, false, null);
}
return this;
}
public final void resolvePath(String str, int i, int i2) {
if (i == i2) {
return;
}
char charAt = str.charAt(i);
if (charAt == '/' || charAt == '\\') {
this.encodedPathSegments.clear();
this.encodedPathSegments.add("");
i++;
} else {
List list = this.encodedPathSegments;
list.set(list.size() - 1, "");
}
while (true) {
int i3 = i;
if (i3 >= i2) {
return;
}
i = Util.delimiterOffset(str, i3, i2, "/\\");
boolean z = i < i2;
push(str, i3, i, z, true);
if (z) {
i++;
}
}
}
public final void push(String str, int i, int i2, boolean z, boolean z2) {
String canonicalize = HttpUrl.canonicalize(str, i, i2, " \"<>^`{}|/\\?#", z2, false, false, true, null);
if (isDot(canonicalize)) {
return;
}
if (isDotDot(canonicalize)) {
pop();
return;
}
if (((String) this.encodedPathSegments.get(r11.size() - 1)).isEmpty()) {
this.encodedPathSegments.set(r11.size() - 1, canonicalize);
} else {
this.encodedPathSegments.add(canonicalize);
}
if (z) {
this.encodedPathSegments.add("");
}
}
public final boolean isDot(String str) {
return str.equals(Consts.STRING_PERIOD) || str.equalsIgnoreCase("%2e");
}
public final boolean isDotDot(String str) {
return str.equals("..") || str.equalsIgnoreCase("%2e.") || str.equalsIgnoreCase(".%2e") || str.equalsIgnoreCase("%2e%2e");
}
public final void pop() {
if (((String) this.encodedPathSegments.remove(r0.size() - 1)).isEmpty() && !this.encodedPathSegments.isEmpty()) {
this.encodedPathSegments.set(r0.size() - 1, "");
} else {
this.encodedPathSegments.add("");
}
}
public static int schemeDelimiterOffset(String str, int i, int i2) {
if (i2 - i < 2) {
return -1;
}
char charAt = str.charAt(i);
if ((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z')) {
while (true) {
i++;
if (i >= i2) {
break;
}
char charAt2 = str.charAt(i);
if (charAt2 < 'a' || charAt2 > 'z') {
if (charAt2 < 'A' || charAt2 > 'Z') {
if (charAt2 < '0' || charAt2 > '9') {
if (charAt2 != '+' && charAt2 != '-' && charAt2 != '.') {
if (charAt2 == ':') {
return i;
}
}
}
}
}
}
}
return -1;
}
public static int slashCount(String str, int i, int i2) {
int i3 = 0;
while (i < i2) {
char charAt = str.charAt(i);
if (charAt != '\\' && charAt != '/') {
break;
}
i3++;
i++;
}
return i3;
}
public static int portColonOffset(String str, int i, int i2) {
while (i < i2) {
char charAt = str.charAt(i);
if (charAt == ':') {
return i;
}
if (charAt == '[') {
do {
i++;
if (i < i2) {
}
} while (str.charAt(i) != ']');
}
i++;
}
return i2;
}
public static String canonicalizeHost(String str, int i, int i2) {
return Util.canonicalizeHost(HttpUrl.percentDecode(str, i, i2, false));
}
public static int parsePort(String str, int i, int i2) {
int parseInt;
try {
parseInt = Integer.parseInt(HttpUrl.canonicalize(str, i, i2, "", false, false, false, true, null));
} catch (NumberFormatException unused) {
}
if (parseInt <= 0 || parseInt > 65535) {
return -1;
}
return parseInt;
}
}
public static String percentDecode(String str, boolean z) {
return percentDecode(str, 0, str.length(), z);
}
public final List percentDecode(List list, boolean z) {
int size = list.size();
ArrayList arrayList = new ArrayList(size);
for (int i = 0; i < size; i++) {
String str = (String) list.get(i);
arrayList.add(str != null ? percentDecode(str, z) : null);
}
return Collections.unmodifiableList(arrayList);
}
public static String percentDecode(String str, int i, int i2, boolean z) {
for (int i3 = i; i3 < i2; i3++) {
char charAt = str.charAt(i3);
if (charAt == '%' || (charAt == '+' && z)) {
Buffer buffer = new Buffer();
buffer.writeUtf8(str, i, i3);
percentDecode(buffer, str, i3, i2, z);
return buffer.readUtf8();
}
}
return str.substring(i, i2);
}
public static void percentDecode(Buffer buffer, String str, int i, int i2, boolean z) {
int i3;
while (i < i2) {
int codePointAt = str.codePointAt(i);
if (codePointAt == 37 && (i3 = i + 2) < i2) {
int decodeHexDigit = Util.decodeHexDigit(str.charAt(i + 1));
int decodeHexDigit2 = Util.decodeHexDigit(str.charAt(i3));
if (decodeHexDigit != -1 && decodeHexDigit2 != -1) {
buffer.writeByte((decodeHexDigit << 4) + decodeHexDigit2);
i = i3;
}
buffer.writeUtf8CodePoint(codePointAt);
} else {
if (codePointAt == 43 && z) {
buffer.writeByte(32);
}
buffer.writeUtf8CodePoint(codePointAt);
}
i += Character.charCount(codePointAt);
}
}
public static boolean percentEncoded(String str, int i, int i2) {
int i3 = i + 2;
return i3 < i2 && str.charAt(i) == '%' && Util.decodeHexDigit(str.charAt(i + 1)) != -1 && Util.decodeHexDigit(str.charAt(i3)) != -1;
}
public static String canonicalize(String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
int i3 = i;
while (i3 < i2) {
int codePointAt = str.codePointAt(i3);
if (codePointAt >= 32 && codePointAt != 127 && (codePointAt < 128 || !z4)) {
if (str2.indexOf(codePointAt) == -1 && ((codePointAt != 37 || (z && (!z2 || percentEncoded(str, i3, i2)))) && (codePointAt != 43 || !z3))) {
i3 += Character.charCount(codePointAt);
}
}
Buffer buffer = new Buffer();
buffer.writeUtf8(str, i, i3);
canonicalize(buffer, str, i3, i2, str2, z, z2, z3, z4, charset);
return buffer.readUtf8();
}
return str.substring(i, i2);
}
public static void canonicalize(Buffer buffer, String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
Buffer buffer2 = null;
while (i < i2) {
int codePointAt = str.codePointAt(i);
if (!z || (codePointAt != 9 && codePointAt != 10 && codePointAt != 12 && codePointAt != 13)) {
if (codePointAt == 43 && z3) {
buffer.writeUtf8(z ? "+" : "%2B");
} else if (codePointAt < 32 || codePointAt == 127 || ((codePointAt >= 128 && z4) || str2.indexOf(codePointAt) != -1 || (codePointAt == 37 && (!z || (z2 && !percentEncoded(str, i, i2)))))) {
if (buffer2 == null) {
buffer2 = new Buffer();
}
if (charset == null || charset.equals(StandardCharsets.UTF_8)) {
buffer2.writeUtf8CodePoint(codePointAt);
} else {
buffer2.writeString(str, i, Character.charCount(codePointAt) + i, charset);
}
while (!buffer2.exhausted()) {
byte readByte = buffer2.readByte();
buffer.writeByte(37);
char[] cArr = HEX_DIGITS;
buffer.writeByte((int) cArr[((readByte & 255) >> 4) & 15]);
buffer.writeByte((int) cArr[readByte & Ascii.SI]);
}
} else {
buffer.writeUtf8CodePoint(codePointAt);
}
}
i += Character.charCount(codePointAt);
}
}
public static String canonicalize(String str, String str2, boolean z, boolean z2, boolean z3, boolean z4) {
return canonicalize(str, 0, str.length(), str2, z, z2, z3, z4, null);
}
}

View File

@@ -0,0 +1,19 @@
package okhttp3;
/* loaded from: classes5.dex */
public interface Interceptor {
public interface Chain {
int connectTimeoutMillis();
Response proceed(Request request);
int readTimeoutMillis();
Request request();
int writeTimeoutMillis();
}
Response intercept(Chain chain);
}

View File

@@ -0,0 +1,92 @@
package okhttp3;
import com.ironsource.nb;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* loaded from: classes5.dex */
public final class MediaType {
public final String charset;
public final String mediaType;
public final String subtype;
public final String type;
public static final Pattern TYPE_SUBTYPE = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");
public static final Pattern PARAMETER = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");
public String toString() {
return this.mediaType;
}
public MediaType(String str, String str2, String str3, String str4) {
this.mediaType = str;
this.type = str2;
this.subtype = str3;
this.charset = str4;
}
public static MediaType get(String str) {
Matcher matcher = TYPE_SUBTYPE.matcher(str);
if (!matcher.lookingAt()) {
throw new IllegalArgumentException("No subtype found for: \"" + str + '\"');
}
String group = matcher.group(1);
Locale locale = Locale.US;
String lowerCase = group.toLowerCase(locale);
String lowerCase2 = matcher.group(2).toLowerCase(locale);
Matcher matcher2 = PARAMETER.matcher(str);
String str2 = null;
for (int end = matcher.end(); end < str.length(); end = matcher2.end()) {
matcher2.region(end, str.length());
if (!matcher2.lookingAt()) {
throw new IllegalArgumentException("Parameter is not formatted correctly: \"" + str.substring(end) + "\" for: \"" + str + '\"');
}
String group2 = matcher2.group(1);
if (group2 != null && group2.equalsIgnoreCase(nb.M)) {
String group3 = matcher2.group(2);
if (group3 != null) {
if (group3.startsWith("'") && group3.endsWith("'") && group3.length() > 2) {
group3 = group3.substring(1, group3.length() - 1);
}
} else {
group3 = matcher2.group(3);
}
if (str2 != null && !group3.equalsIgnoreCase(str2)) {
throw new IllegalArgumentException("Multiple charsets defined: \"" + str2 + "\" and: \"" + group3 + "\" for: \"" + str + '\"');
}
str2 = group3;
}
}
return new MediaType(str, lowerCase, lowerCase2, str2);
}
public static MediaType parse(String str) {
try {
return get(str);
} catch (IllegalArgumentException unused) {
return null;
}
}
public Charset charset() {
return charset(null);
}
public Charset charset(Charset charset) {
try {
String str = this.charset;
return str != null ? Charset.forName(str) : charset;
} catch (IllegalArgumentException unused) {
return charset;
}
}
public boolean equals(Object obj) {
return (obj instanceof MediaType) && ((MediaType) obj).mediaType.equals(this.mediaType);
}
public int hashCode() {
return this.mediaType.hashCode();
}
}

View File

@@ -0,0 +1,434 @@
package okhttp3;
import java.net.Proxy;
import java.net.ProxySelector;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.Headers;
import okhttp3.Response;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.cache.InternalCache;
import okhttp3.internal.connection.Exchange;
import okhttp3.internal.connection.RealConnectionPool;
import okhttp3.internal.platform.Platform;
import okhttp3.internal.proxy.NullProxySelector;
import okhttp3.internal.tls.CertificateChainCleaner;
import okhttp3.internal.tls.OkHostnameVerifier;
/* loaded from: classes5.dex */
public class OkHttpClient implements Cloneable, Call.Factory {
public final Authenticator authenticator;
public final Cache cache;
public final int callTimeout;
public final CertificateChainCleaner certificateChainCleaner;
public final CertificatePinner certificatePinner;
public final int connectTimeout;
public final ConnectionPool connectionPool;
public final List connectionSpecs;
public final CookieJar cookieJar;
public final Dispatcher dispatcher;
public final Dns dns;
public final EventListener.Factory eventListenerFactory;
public final boolean followRedirects;
public final boolean followSslRedirects;
public final HostnameVerifier hostnameVerifier;
public final List interceptors;
public final InternalCache internalCache;
public final List networkInterceptors;
public final int pingInterval;
public final List protocols;
public final Proxy proxy;
public final Authenticator proxyAuthenticator;
public final ProxySelector proxySelector;
public final int readTimeout;
public final boolean retryOnConnectionFailure;
public final SocketFactory socketFactory;
public final SSLSocketFactory sslSocketFactory;
public final int writeTimeout;
public static final List DEFAULT_PROTOCOLS = Util.immutableList(Protocol.HTTP_2, Protocol.HTTP_1_1);
public static final List DEFAULT_CONNECTION_SPECS = Util.immutableList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT);
public Authenticator authenticator() {
return this.authenticator;
}
public int callTimeoutMillis() {
return this.callTimeout;
}
public CertificatePinner certificatePinner() {
return this.certificatePinner;
}
public int connectTimeoutMillis() {
return this.connectTimeout;
}
public ConnectionPool connectionPool() {
return this.connectionPool;
}
public List connectionSpecs() {
return this.connectionSpecs;
}
public CookieJar cookieJar() {
return this.cookieJar;
}
public Dispatcher dispatcher() {
return this.dispatcher;
}
public Dns dns() {
return this.dns;
}
public EventListener.Factory eventListenerFactory() {
return this.eventListenerFactory;
}
public boolean followRedirects() {
return this.followRedirects;
}
public boolean followSslRedirects() {
return this.followSslRedirects;
}
public HostnameVerifier hostnameVerifier() {
return this.hostnameVerifier;
}
public List interceptors() {
return this.interceptors;
}
public List networkInterceptors() {
return this.networkInterceptors;
}
public int pingIntervalMillis() {
return this.pingInterval;
}
public List protocols() {
return this.protocols;
}
public Proxy proxy() {
return this.proxy;
}
public Authenticator proxyAuthenticator() {
return this.proxyAuthenticator;
}
public ProxySelector proxySelector() {
return this.proxySelector;
}
public int readTimeoutMillis() {
return this.readTimeout;
}
public boolean retryOnConnectionFailure() {
return this.retryOnConnectionFailure;
}
public SocketFactory socketFactory() {
return this.socketFactory;
}
public SSLSocketFactory sslSocketFactory() {
return this.sslSocketFactory;
}
public int writeTimeoutMillis() {
return this.writeTimeout;
}
static {
Internal.instance = new Internal() { // from class: okhttp3.OkHttpClient.1
@Override // okhttp3.internal.Internal
public void addLenient(Headers.Builder builder, String str) {
builder.addLenient(str);
}
@Override // okhttp3.internal.Internal
public void addLenient(Headers.Builder builder, String str, String str2) {
builder.addLenient(str, str2);
}
@Override // okhttp3.internal.Internal
public RealConnectionPool realConnectionPool(ConnectionPool connectionPool) {
return connectionPool.delegate;
}
@Override // okhttp3.internal.Internal
public boolean equalsNonHost(Address address, Address address2) {
return address.equalsNonHost(address2);
}
@Override // okhttp3.internal.Internal
public int code(Response.Builder builder) {
return builder.code;
}
@Override // okhttp3.internal.Internal
public void apply(ConnectionSpec connectionSpec, SSLSocket sSLSocket, boolean z) {
connectionSpec.apply(sSLSocket, z);
}
@Override // okhttp3.internal.Internal
public void initExchange(Response.Builder builder, Exchange exchange) {
builder.initExchange(exchange);
}
@Override // okhttp3.internal.Internal
public Exchange exchange(Response response) {
return response.exchange;
}
};
}
public OkHttpClient() {
this(new Builder());
}
public OkHttpClient(Builder builder) {
boolean z;
this.dispatcher = builder.dispatcher;
this.proxy = builder.proxy;
this.protocols = builder.protocols;
List list = builder.connectionSpecs;
this.connectionSpecs = list;
this.interceptors = Util.immutableList(builder.interceptors);
this.networkInterceptors = Util.immutableList(builder.networkInterceptors);
this.eventListenerFactory = builder.eventListenerFactory;
this.proxySelector = builder.proxySelector;
this.cookieJar = builder.cookieJar;
this.cache = builder.cache;
this.internalCache = builder.internalCache;
this.socketFactory = builder.socketFactory;
Iterator it = list.iterator();
loop0: while (true) {
z = false;
while (it.hasNext()) {
z = (z || ((ConnectionSpec) it.next()).isTls()) ? true : z;
}
}
SSLSocketFactory sSLSocketFactory = builder.sslSocketFactory;
if (sSLSocketFactory != null || !z) {
this.sslSocketFactory = sSLSocketFactory;
this.certificateChainCleaner = builder.certificateChainCleaner;
} else {
X509TrustManager platformTrustManager = Util.platformTrustManager();
this.sslSocketFactory = newSslSocketFactory(platformTrustManager);
this.certificateChainCleaner = CertificateChainCleaner.get(platformTrustManager);
}
if (this.sslSocketFactory != null) {
Platform.get().configureSslSocketFactory(this.sslSocketFactory);
}
this.hostnameVerifier = builder.hostnameVerifier;
this.certificatePinner = builder.certificatePinner.withCertificateChainCleaner(this.certificateChainCleaner);
this.proxyAuthenticator = builder.proxyAuthenticator;
this.authenticator = builder.authenticator;
this.connectionPool = builder.connectionPool;
this.dns = builder.dns;
this.followSslRedirects = builder.followSslRedirects;
this.followRedirects = builder.followRedirects;
this.retryOnConnectionFailure = builder.retryOnConnectionFailure;
this.callTimeout = builder.callTimeout;
this.connectTimeout = builder.connectTimeout;
this.readTimeout = builder.readTimeout;
this.writeTimeout = builder.writeTimeout;
this.pingInterval = builder.pingInterval;
if (this.interceptors.contains(null)) {
throw new IllegalStateException("Null interceptor: " + this.interceptors);
}
if (this.networkInterceptors.contains(null)) {
throw new IllegalStateException("Null network interceptor: " + this.networkInterceptors);
}
}
public static SSLSocketFactory newSslSocketFactory(X509TrustManager x509TrustManager) {
try {
SSLContext sSLContext = Platform.get().getSSLContext();
sSLContext.init(null, new TrustManager[]{x509TrustManager}, null);
return sSLContext.getSocketFactory();
} catch (GeneralSecurityException e) {
throw new AssertionError("No System TLS", e);
}
}
public InternalCache internalCache() {
Cache cache = this.cache;
return cache != null ? cache.internalCache : this.internalCache;
}
@Override // okhttp3.Call.Factory
public Call newCall(Request request) {
return RealCall.newRealCall(this, request, false);
}
public Builder newBuilder() {
return new Builder(this);
}
public static final class Builder {
public Authenticator authenticator;
public Cache cache;
public int callTimeout;
public CertificateChainCleaner certificateChainCleaner;
public CertificatePinner certificatePinner;
public int connectTimeout;
public ConnectionPool connectionPool;
public List connectionSpecs;
public CookieJar cookieJar;
public Dispatcher dispatcher;
public Dns dns;
public EventListener.Factory eventListenerFactory;
public boolean followRedirects;
public boolean followSslRedirects;
public HostnameVerifier hostnameVerifier;
public final List interceptors;
public InternalCache internalCache;
public final List networkInterceptors;
public int pingInterval;
public List protocols;
public Proxy proxy;
public Authenticator proxyAuthenticator;
public ProxySelector proxySelector;
public int readTimeout;
public boolean retryOnConnectionFailure;
public SocketFactory socketFactory;
public SSLSocketFactory sslSocketFactory;
public int writeTimeout;
public Builder cache(Cache cache) {
this.cache = cache;
this.internalCache = null;
return this;
}
public Builder followRedirects(boolean z) {
this.followRedirects = z;
return this;
}
public Builder followSslRedirects(boolean z) {
this.followSslRedirects = z;
return this;
}
public Builder() {
this.interceptors = new ArrayList();
this.networkInterceptors = new ArrayList();
this.dispatcher = new Dispatcher();
this.protocols = OkHttpClient.DEFAULT_PROTOCOLS;
this.connectionSpecs = OkHttpClient.DEFAULT_CONNECTION_SPECS;
this.eventListenerFactory = EventListener.factory(EventListener.NONE);
ProxySelector proxySelector = ProxySelector.getDefault();
this.proxySelector = proxySelector;
if (proxySelector == null) {
this.proxySelector = new NullProxySelector();
}
this.cookieJar = CookieJar.NO_COOKIES;
this.socketFactory = SocketFactory.getDefault();
this.hostnameVerifier = OkHostnameVerifier.INSTANCE;
this.certificatePinner = CertificatePinner.DEFAULT;
Authenticator authenticator = Authenticator.NONE;
this.proxyAuthenticator = authenticator;
this.authenticator = authenticator;
this.connectionPool = new ConnectionPool();
this.dns = Dns.SYSTEM;
this.followSslRedirects = true;
this.followRedirects = true;
this.retryOnConnectionFailure = true;
this.callTimeout = 0;
this.connectTimeout = 10000;
this.readTimeout = 10000;
this.writeTimeout = 10000;
this.pingInterval = 0;
}
public Builder(OkHttpClient okHttpClient) {
ArrayList arrayList = new ArrayList();
this.interceptors = arrayList;
ArrayList arrayList2 = new ArrayList();
this.networkInterceptors = arrayList2;
this.dispatcher = okHttpClient.dispatcher;
this.proxy = okHttpClient.proxy;
this.protocols = okHttpClient.protocols;
this.connectionSpecs = okHttpClient.connectionSpecs;
arrayList.addAll(okHttpClient.interceptors);
arrayList2.addAll(okHttpClient.networkInterceptors);
this.eventListenerFactory = okHttpClient.eventListenerFactory;
this.proxySelector = okHttpClient.proxySelector;
this.cookieJar = okHttpClient.cookieJar;
this.internalCache = okHttpClient.internalCache;
this.cache = okHttpClient.cache;
this.socketFactory = okHttpClient.socketFactory;
this.sslSocketFactory = okHttpClient.sslSocketFactory;
this.certificateChainCleaner = okHttpClient.certificateChainCleaner;
this.hostnameVerifier = okHttpClient.hostnameVerifier;
this.certificatePinner = okHttpClient.certificatePinner;
this.proxyAuthenticator = okHttpClient.proxyAuthenticator;
this.authenticator = okHttpClient.authenticator;
this.connectionPool = okHttpClient.connectionPool;
this.dns = okHttpClient.dns;
this.followSslRedirects = okHttpClient.followSslRedirects;
this.followRedirects = okHttpClient.followRedirects;
this.retryOnConnectionFailure = okHttpClient.retryOnConnectionFailure;
this.callTimeout = okHttpClient.callTimeout;
this.connectTimeout = okHttpClient.connectTimeout;
this.readTimeout = okHttpClient.readTimeout;
this.writeTimeout = okHttpClient.writeTimeout;
this.pingInterval = okHttpClient.pingInterval;
}
public Builder connectTimeout(long j, TimeUnit timeUnit) {
this.connectTimeout = Util.checkDuration("timeout", j, timeUnit);
return this;
}
public Builder readTimeout(long j, TimeUnit timeUnit) {
this.readTimeout = Util.checkDuration("timeout", j, timeUnit);
return this;
}
public Builder proxySelector(ProxySelector proxySelector) {
if (proxySelector == null) {
throw new NullPointerException("proxySelector == null");
}
this.proxySelector = proxySelector;
return this;
}
public Builder addInterceptor(Interceptor interceptor) {
if (interceptor == null) {
throw new IllegalArgumentException("interceptor == null");
}
this.interceptors.add(interceptor);
return this;
}
public OkHttpClient build() {
return new OkHttpClient(this);
}
}
}

View File

@@ -0,0 +1,52 @@
package okhttp3;
import java.io.IOException;
/* loaded from: classes5.dex */
public enum Protocol {
HTTP_1_0("http/1.0"),
HTTP_1_1("http/1.1"),
SPDY_3("spdy/3.1"),
HTTP_2("h2"),
H2_PRIOR_KNOWLEDGE("h2_prior_knowledge"),
QUIC("quic");
private final String protocol;
@Override // java.lang.Enum
public String toString() {
return this.protocol;
}
Protocol(String str) {
this.protocol = str;
}
public static Protocol get(String str) throws IOException {
Protocol protocol = HTTP_1_0;
if (str.equals(protocol.protocol)) {
return protocol;
}
Protocol protocol2 = HTTP_1_1;
if (str.equals(protocol2.protocol)) {
return protocol2;
}
Protocol protocol3 = H2_PRIOR_KNOWLEDGE;
if (str.equals(protocol3.protocol)) {
return protocol3;
}
Protocol protocol4 = HTTP_2;
if (str.equals(protocol4.protocol)) {
return protocol4;
}
Protocol protocol5 = SPDY_3;
if (str.equals(protocol5.protocol)) {
return protocol5;
}
Protocol protocol6 = QUIC;
if (str.equals(protocol6.protocol)) {
return protocol6;
}
throw new IOException("Unexpected protocol: " + str);
}
}

View File

@@ -0,0 +1,276 @@
package okhttp3;
import androidx.core.app.NotificationCompat;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import okhttp3.internal.NamedRunnable;
import okhttp3.internal.connection.Transmitter;
import okhttp3.internal.platform.Platform;
/* loaded from: classes5.dex */
public final class RealCall implements Call {
public final OkHttpClient client;
public boolean executed;
public final boolean forWebSocket;
public final Request originalRequest;
public Transmitter transmitter;
@Override // okhttp3.Call
public Request request() {
return this.originalRequest;
}
public RealCall(OkHttpClient okHttpClient, Request request, boolean z) {
this.client = okHttpClient;
this.originalRequest = request;
this.forWebSocket = z;
}
public static RealCall newRealCall(OkHttpClient okHttpClient, Request request, boolean z) {
RealCall realCall = new RealCall(okHttpClient, request, z);
realCall.transmitter = new Transmitter(okHttpClient, realCall);
return realCall;
}
@Override // okhttp3.Call
public Response execute() {
synchronized (this) {
if (this.executed) {
throw new IllegalStateException("Already Executed");
}
this.executed = true;
}
this.transmitter.timeoutEnter();
this.transmitter.callStart();
try {
this.client.dispatcher().executed(this);
return getResponseWithInterceptorChain();
} finally {
this.client.dispatcher().finished(this);
}
}
@Override // okhttp3.Call
public void enqueue(Callback callback) {
synchronized (this) {
if (this.executed) {
throw new IllegalStateException("Already Executed");
}
this.executed = true;
}
this.transmitter.callStart();
this.client.dispatcher().enqueue(new AsyncCall(callback));
}
@Override // okhttp3.Call
public void cancel() {
this.transmitter.cancel();
}
@Override // okhttp3.Call
public boolean isCanceled() {
return this.transmitter.isCanceled();
}
public RealCall clone() {
return newRealCall(this.client, this.originalRequest, this.forWebSocket);
}
public final class AsyncCall extends NamedRunnable {
public volatile AtomicInteger callsPerHost;
public final Callback responseCallback;
public AtomicInteger callsPerHost() {
return this.callsPerHost;
}
public RealCall get() {
return RealCall.this;
}
public AsyncCall(Callback callback) {
super("OkHttp %s", RealCall.this.redactedUrl());
this.callsPerHost = new AtomicInteger(0);
this.responseCallback = callback;
}
public void reuseCallsPerHostFrom(AsyncCall asyncCall) {
this.callsPerHost = asyncCall.callsPerHost;
}
public String host() {
return RealCall.this.originalRequest.url().host();
}
public void executeOn(ExecutorService executorService) {
try {
try {
executorService.execute(this);
} catch (RejectedExecutionException e) {
InterruptedIOException interruptedIOException = new InterruptedIOException("executor rejected");
interruptedIOException.initCause(e);
RealCall.this.transmitter.noMoreExchanges(interruptedIOException);
this.responseCallback.onFailure(RealCall.this, interruptedIOException);
RealCall.this.client.dispatcher().finished(this);
}
} catch (Throwable th) {
RealCall.this.client.dispatcher().finished(this);
throw th;
}
}
@Override // okhttp3.internal.NamedRunnable
public void execute() {
boolean z;
Throwable th;
IOException e;
RealCall.this.transmitter.timeoutEnter();
try {
try {
z = true;
try {
this.responseCallback.onResponse(RealCall.this, RealCall.this.getResponseWithInterceptorChain());
} catch (IOException e2) {
e = e2;
if (z) {
Platform.get().log(4, "Callback failure for " + RealCall.this.toLoggableString(), e);
} else {
this.responseCallback.onFailure(RealCall.this, e);
}
RealCall.this.client.dispatcher().finished(this);
} catch (Throwable th2) {
th = th2;
RealCall.this.cancel();
if (!z) {
IOException iOException = new IOException("canceled due to " + th);
iOException.addSuppressed(th);
this.responseCallback.onFailure(RealCall.this, iOException);
}
throw th;
}
} catch (Throwable th3) {
RealCall.this.client.dispatcher().finished(this);
throw th3;
}
} catch (IOException e3) {
z = false;
e = e3;
} catch (Throwable th4) {
z = false;
th = th4;
}
RealCall.this.client.dispatcher().finished(this);
}
}
public String toLoggableString() {
StringBuilder sb = new StringBuilder();
sb.append(isCanceled() ? "canceled " : "");
sb.append(this.forWebSocket ? "web socket" : NotificationCompat.CATEGORY_CALL);
sb.append(" to ");
sb.append(redactedUrl());
return sb.toString();
}
public String redactedUrl() {
return this.originalRequest.url().redact();
}
/* JADX WARN: Removed duplicated region for block: B:23:0x00a6 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public okhttp3.Response getResponseWithInterceptorChain() {
/*
r12 = this;
java.util.ArrayList r1 = new java.util.ArrayList
r1.<init>()
okhttp3.OkHttpClient r0 = r12.client
java.util.List r0 = r0.interceptors()
r1.addAll(r0)
okhttp3.internal.http.RetryAndFollowUpInterceptor r0 = new okhttp3.internal.http.RetryAndFollowUpInterceptor
okhttp3.OkHttpClient r2 = r12.client
r0.<init>(r2)
r1.add(r0)
okhttp3.internal.http.BridgeInterceptor r0 = new okhttp3.internal.http.BridgeInterceptor
okhttp3.OkHttpClient r2 = r12.client
okhttp3.CookieJar r2 = r2.cookieJar()
r0.<init>(r2)
r1.add(r0)
okhttp3.internal.cache.CacheInterceptor r0 = new okhttp3.internal.cache.CacheInterceptor
okhttp3.OkHttpClient r2 = r12.client
okhttp3.internal.cache.InternalCache r2 = r2.internalCache()
r0.<init>(r2)
r1.add(r0)
okhttp3.internal.connection.ConnectInterceptor r0 = new okhttp3.internal.connection.ConnectInterceptor
okhttp3.OkHttpClient r2 = r12.client
r0.<init>(r2)
r1.add(r0)
boolean r0 = r12.forWebSocket
if (r0 != 0) goto L4b
okhttp3.OkHttpClient r0 = r12.client
java.util.List r0 = r0.networkInterceptors()
r1.addAll(r0)
L4b:
okhttp3.internal.http.CallServerInterceptor r0 = new okhttp3.internal.http.CallServerInterceptor
boolean r2 = r12.forWebSocket
r0.<init>(r2)
r1.add(r0)
okhttp3.internal.http.RealInterceptorChain r10 = new okhttp3.internal.http.RealInterceptorChain
okhttp3.internal.connection.Transmitter r2 = r12.transmitter
r3 = 0
r4 = 0
okhttp3.Request r5 = r12.originalRequest
okhttp3.OkHttpClient r0 = r12.client
int r7 = r0.connectTimeoutMillis()
okhttp3.OkHttpClient r0 = r12.client
int r8 = r0.readTimeoutMillis()
okhttp3.OkHttpClient r0 = r12.client
int r9 = r0.writeTimeoutMillis()
r0 = r10
r6 = r12
r0.<init>(r1, r2, r3, r4, r5, r6, r7, r8, r9)
r0 = 0
r1 = 0
okhttp3.Request r2 = r12.originalRequest // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
okhttp3.Response r2 = r10.proceed(r2) // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
okhttp3.internal.connection.Transmitter r3 = r12.transmitter // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
boolean r3 = r3.isCanceled() // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
if (r3 != 0) goto L8a
okhttp3.internal.connection.Transmitter r1 = r12.transmitter
r1.noMoreExchanges(r0)
return r2
L8a:
okhttp3.internal.Util.closeQuietly(r2) // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
java.io.IOException r2 = new java.io.IOException // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
java.lang.String r3 = "Canceled"
r2.<init>(r3) // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
throw r2 // Catch: java.lang.Throwable -> L95 java.io.IOException -> L97
L95:
r2 = move-exception
goto La4
L97:
r1 = move-exception
r2 = 1
okhttp3.internal.connection.Transmitter r3 = r12.transmitter // Catch: java.lang.Throwable -> La0
java.io.IOException r1 = r3.noMoreExchanges(r1) // Catch: java.lang.Throwable -> La0
throw r1 // Catch: java.lang.Throwable -> La0
La0:
r1 = move-exception
r11 = r2
r2 = r1
r1 = r11
La4:
if (r1 != 0) goto Lab
okhttp3.internal.connection.Transmitter r1 = r12.transmitter
r1.noMoreExchanges(r0)
Lab:
throw r2
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.RealCall.getResponseWithInterceptorChain():okhttp3.Response");
}
}

View File

@@ -0,0 +1,175 @@
package okhttp3;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Headers;
import okhttp3.internal.Util;
import okhttp3.internal.http.HttpMethod;
/* loaded from: classes5.dex */
public final class Request {
public final RequestBody body;
public volatile CacheControl cacheControl;
public final Headers headers;
public final String method;
public final Map tags;
public final HttpUrl url;
public RequestBody body() {
return this.body;
}
public Headers headers() {
return this.headers;
}
public String method() {
return this.method;
}
public HttpUrl url() {
return this.url;
}
public Request(Builder builder) {
this.url = builder.url;
this.method = builder.method;
this.headers = builder.headers.build();
this.body = builder.body;
this.tags = Util.immutableMap(builder.tags);
}
public String header(String str) {
return this.headers.get(str);
}
public List headers(String str) {
return this.headers.values(str);
}
public Builder newBuilder() {
return new Builder(this);
}
public CacheControl cacheControl() {
CacheControl cacheControl = this.cacheControl;
if (cacheControl != null) {
return cacheControl;
}
CacheControl parse = CacheControl.parse(this.headers);
this.cacheControl = parse;
return parse;
}
public boolean isHttps() {
return this.url.isHttps();
}
public String toString() {
return "Request{method=" + this.method + ", url=" + this.url + ", tags=" + this.tags + '}';
}
public static class Builder {
public RequestBody body;
public Headers.Builder headers;
public String method;
public Map tags;
public HttpUrl url;
public Builder() {
this.tags = Collections.emptyMap();
this.method = "GET";
this.headers = new Headers.Builder();
}
public Builder(Request request) {
Map linkedHashMap;
this.tags = Collections.emptyMap();
this.url = request.url;
this.method = request.method;
this.body = request.body;
if (request.tags.isEmpty()) {
linkedHashMap = Collections.emptyMap();
} else {
linkedHashMap = new LinkedHashMap(request.tags);
}
this.tags = linkedHashMap;
this.headers = request.headers.newBuilder();
}
public Builder url(HttpUrl httpUrl) {
if (httpUrl == null) {
throw new NullPointerException("url == null");
}
this.url = httpUrl;
return this;
}
public Builder url(String str) {
if (str == null) {
throw new NullPointerException("url == null");
}
if (str.regionMatches(true, 0, "ws:", 0, 3)) {
str = "http:" + str.substring(3);
} else if (str.regionMatches(true, 0, "wss:", 0, 4)) {
str = "https:" + str.substring(4);
}
return url(HttpUrl.get(str));
}
public Builder header(String str, String str2) {
this.headers.set(str, str2);
return this;
}
public Builder addHeader(String str, String str2) {
this.headers.add(str, str2);
return this;
}
public Builder removeHeader(String str) {
this.headers.removeAll(str);
return this;
}
public Builder headers(Headers headers) {
this.headers = headers.newBuilder();
return this;
}
public Builder get() {
return method("GET", null);
}
public Builder post(RequestBody requestBody) {
return method("POST", requestBody);
}
public Builder method(String str, RequestBody requestBody) {
if (str == null) {
throw new NullPointerException("method == null");
}
if (str.length() == 0) {
throw new IllegalArgumentException("method.length() == 0");
}
if (requestBody != null && !HttpMethod.permitsRequestBody(str)) {
throw new IllegalArgumentException("method " + str + " must not have a request body.");
}
if (requestBody != null || !HttpMethod.requiresRequestBody(str)) {
this.method = str;
this.body = requestBody;
return this;
}
throw new IllegalArgumentException("method " + str + " must have a request body.");
}
public Request build() {
if (this.url == null) {
throw new IllegalStateException("url == null");
}
return new Request(this);
}
}
}

View File

@@ -0,0 +1,127 @@
package okhttp3;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import okhttp3.internal.Util;
import okio.BufferedSink;
import okio.ByteString;
import okio.Okio;
import okio.Source;
/* loaded from: classes5.dex */
public abstract class RequestBody {
public abstract long contentLength();
public abstract MediaType contentType();
public boolean isDuplex() {
return false;
}
public boolean isOneShot() {
return false;
}
public abstract void writeTo(BufferedSink bufferedSink);
public static RequestBody create(MediaType mediaType, String str) {
Charset charset = StandardCharsets.UTF_8;
if (mediaType != null) {
Charset charset2 = mediaType.charset();
if (charset2 == null) {
mediaType = MediaType.parse(mediaType + "; charset=utf-8");
} else {
charset = charset2;
}
}
return create(mediaType, str.getBytes(charset));
}
public static RequestBody create(final MediaType mediaType, final ByteString byteString) {
return new RequestBody() { // from class: okhttp3.RequestBody.1
@Override // okhttp3.RequestBody
public MediaType contentType() {
return MediaType.this;
}
@Override // okhttp3.RequestBody
public long contentLength() {
return byteString.size();
}
@Override // okhttp3.RequestBody
public void writeTo(BufferedSink bufferedSink) {
bufferedSink.write(byteString);
}
};
}
public static RequestBody create(MediaType mediaType, byte[] bArr) {
return create(mediaType, bArr, 0, bArr.length);
}
public static RequestBody create(final MediaType mediaType, final byte[] bArr, final int i, final int i2) {
if (bArr == null) {
throw new NullPointerException("content == null");
}
Util.checkOffsetAndCount(bArr.length, i, i2);
return new RequestBody() { // from class: okhttp3.RequestBody.2
@Override // okhttp3.RequestBody
public long contentLength() {
return i2;
}
@Override // okhttp3.RequestBody
public MediaType contentType() {
return MediaType.this;
}
@Override // okhttp3.RequestBody
public void writeTo(BufferedSink bufferedSink) {
bufferedSink.write(bArr, i, i2);
}
};
}
public static RequestBody create(final MediaType mediaType, final File file) {
if (file == null) {
throw new NullPointerException("file == null");
}
return new RequestBody() { // from class: okhttp3.RequestBody.3
@Override // okhttp3.RequestBody
public MediaType contentType() {
return MediaType.this;
}
@Override // okhttp3.RequestBody
public long contentLength() {
return file.length();
}
@Override // okhttp3.RequestBody
public void writeTo(BufferedSink bufferedSink) {
Source source = Okio.source(file);
try {
bufferedSink.writeAll(source);
if (source != null) {
source.close();
}
} catch (Throwable th) {
try {
throw th;
} catch (Throwable th2) {
if (source != null) {
try {
source.close();
} catch (Throwable th3) {
th.addSuppressed(th3);
}
}
throw th2;
}
}
}
};
}
}

View File

@@ -0,0 +1,287 @@
package okhttp3;
import java.io.Closeable;
import okhttp3.Headers;
import okhttp3.internal.connection.Exchange;
/* loaded from: classes5.dex */
public final class Response implements Closeable {
public final ResponseBody body;
public volatile CacheControl cacheControl;
public final Response cacheResponse;
public final int code;
public final Exchange exchange;
public final Handshake handshake;
public final Headers headers;
public final String message;
public final Response networkResponse;
public final Response priorResponse;
public final Protocol protocol;
public final long receivedResponseAtMillis;
public final Request request;
public final long sentRequestAtMillis;
public ResponseBody body() {
return this.body;
}
public Response cacheResponse() {
return this.cacheResponse;
}
public int code() {
return this.code;
}
public Handshake handshake() {
return this.handshake;
}
public Headers headers() {
return this.headers;
}
public boolean isSuccessful() {
int i = this.code;
return i >= 200 && i < 300;
}
public String message() {
return this.message;
}
public Response networkResponse() {
return this.networkResponse;
}
public Response priorResponse() {
return this.priorResponse;
}
public Protocol protocol() {
return this.protocol;
}
public long receivedResponseAtMillis() {
return this.receivedResponseAtMillis;
}
public Request request() {
return this.request;
}
public long sentRequestAtMillis() {
return this.sentRequestAtMillis;
}
public Response(Builder builder) {
this.request = builder.request;
this.protocol = builder.protocol;
this.code = builder.code;
this.message = builder.message;
this.handshake = builder.handshake;
this.headers = builder.headers.build();
this.body = builder.body;
this.networkResponse = builder.networkResponse;
this.cacheResponse = builder.cacheResponse;
this.priorResponse = builder.priorResponse;
this.sentRequestAtMillis = builder.sentRequestAtMillis;
this.receivedResponseAtMillis = builder.receivedResponseAtMillis;
this.exchange = builder.exchange;
}
public String header(String str) {
return header(str, null);
}
public String header(String str, String str2) {
String str3 = this.headers.get(str);
return str3 != null ? str3 : str2;
}
public Builder newBuilder() {
return new Builder(this);
}
public CacheControl cacheControl() {
CacheControl cacheControl = this.cacheControl;
if (cacheControl != null) {
return cacheControl;
}
CacheControl parse = CacheControl.parse(this.headers);
this.cacheControl = parse;
return parse;
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() {
ResponseBody responseBody = this.body;
if (responseBody == null) {
throw new IllegalStateException("response is not eligible for a body and must not be closed");
}
responseBody.close();
}
public String toString() {
return "Response{protocol=" + this.protocol + ", code=" + this.code + ", message=" + this.message + ", url=" + this.request.url() + '}';
}
public static class Builder {
public ResponseBody body;
public Response cacheResponse;
public int code;
public Exchange exchange;
public Handshake handshake;
public Headers.Builder headers;
public String message;
public Response networkResponse;
public Response priorResponse;
public Protocol protocol;
public long receivedResponseAtMillis;
public Request request;
public long sentRequestAtMillis;
public Builder body(ResponseBody responseBody) {
this.body = responseBody;
return this;
}
public Builder code(int i) {
this.code = i;
return this;
}
public Builder handshake(Handshake handshake) {
this.handshake = handshake;
return this;
}
public void initExchange(Exchange exchange) {
this.exchange = exchange;
}
public Builder message(String str) {
this.message = str;
return this;
}
public Builder protocol(Protocol protocol) {
this.protocol = protocol;
return this;
}
public Builder receivedResponseAtMillis(long j) {
this.receivedResponseAtMillis = j;
return this;
}
public Builder request(Request request) {
this.request = request;
return this;
}
public Builder sentRequestAtMillis(long j) {
this.sentRequestAtMillis = j;
return this;
}
public Builder() {
this.code = -1;
this.headers = new Headers.Builder();
}
public Builder(Response response) {
this.code = -1;
this.request = response.request;
this.protocol = response.protocol;
this.code = response.code;
this.message = response.message;
this.handshake = response.handshake;
this.headers = response.headers.newBuilder();
this.body = response.body;
this.networkResponse = response.networkResponse;
this.cacheResponse = response.cacheResponse;
this.priorResponse = response.priorResponse;
this.sentRequestAtMillis = response.sentRequestAtMillis;
this.receivedResponseAtMillis = response.receivedResponseAtMillis;
this.exchange = response.exchange;
}
public Builder header(String str, String str2) {
this.headers.set(str, str2);
return this;
}
public Builder addHeader(String str, String str2) {
this.headers.add(str, str2);
return this;
}
public Builder headers(Headers headers) {
this.headers = headers.newBuilder();
return this;
}
public Builder networkResponse(Response response) {
if (response != null) {
checkSupportResponse("networkResponse", response);
}
this.networkResponse = response;
return this;
}
public Builder cacheResponse(Response response) {
if (response != null) {
checkSupportResponse("cacheResponse", response);
}
this.cacheResponse = response;
return this;
}
public final void checkSupportResponse(String str, Response response) {
if (response.body != null) {
throw new IllegalArgumentException(str + ".body != null");
}
if (response.networkResponse != null) {
throw new IllegalArgumentException(str + ".networkResponse != null");
}
if (response.cacheResponse != null) {
throw new IllegalArgumentException(str + ".cacheResponse != null");
}
if (response.priorResponse == null) {
return;
}
throw new IllegalArgumentException(str + ".priorResponse != null");
}
public Builder priorResponse(Response response) {
if (response != null) {
checkPriorResponse(response);
}
this.priorResponse = response;
return this;
}
public final void checkPriorResponse(Response response) {
if (response.body != null) {
throw new IllegalArgumentException("priorResponse.body != null");
}
}
public Response build() {
if (this.request == null) {
throw new IllegalStateException("request == null");
}
if (this.protocol == null) {
throw new IllegalStateException("protocol == null");
}
if (this.code >= 0) {
if (this.message == null) {
throw new IllegalStateException("message == null");
}
return new Response(this);
}
throw new IllegalStateException("code < 0: " + this.code);
}
}
}

View File

@@ -0,0 +1,176 @@
package okhttp3;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import okhttp3.internal.Util;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
/* loaded from: classes5.dex */
public abstract class ResponseBody implements Closeable {
private Reader reader;
public abstract long contentLength();
public abstract MediaType contentType();
public abstract BufferedSource source();
public final InputStream byteStream() {
return source().inputStream();
}
public final byte[] bytes() throws IOException {
long contentLength = contentLength();
if (contentLength > 2147483647L) {
throw new IOException("Cannot buffer entire body for content length: " + contentLength);
}
BufferedSource source = source();
try {
byte[] readByteArray = source.readByteArray();
$closeResource(null, source);
if (contentLength == -1 || contentLength == readByteArray.length) {
return readByteArray;
}
throw new IOException("Content-Length (" + contentLength + ") and stream length (" + readByteArray.length + ") disagree");
} finally {
}
}
public static /* synthetic */ void $closeResource(Throwable th, AutoCloseable autoCloseable) {
if (th == null) {
autoCloseable.close();
return;
}
try {
autoCloseable.close();
} catch (Throwable th2) {
th.addSuppressed(th2);
}
}
public final Reader charStream() {
Reader reader = this.reader;
if (reader != null) {
return reader;
}
BomAwareReader bomAwareReader = new BomAwareReader(source(), charset());
this.reader = bomAwareReader;
return bomAwareReader;
}
public final String string() throws IOException {
BufferedSource source = source();
try {
String readString = source.readString(Util.bomAwareCharset(source, charset()));
$closeResource(null, source);
return readString;
} catch (Throwable th) {
try {
throw th;
} catch (Throwable th2) {
if (source != null) {
$closeResource(th, source);
}
throw th2;
}
}
}
public final Charset charset() {
MediaType contentType = contentType();
return contentType != null ? contentType.charset(StandardCharsets.UTF_8) : StandardCharsets.UTF_8;
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() {
Util.closeQuietly(source());
}
public static ResponseBody create(MediaType mediaType, String str) {
Charset charset = StandardCharsets.UTF_8;
if (mediaType != null) {
Charset charset2 = mediaType.charset();
if (charset2 == null) {
mediaType = MediaType.parse(mediaType + "; charset=utf-8");
} else {
charset = charset2;
}
}
Buffer writeString = new Buffer().writeString(str, charset);
return create(mediaType, writeString.size(), writeString);
}
public static ResponseBody create(MediaType mediaType, byte[] bArr) {
return create(mediaType, bArr.length, new Buffer().write(bArr));
}
public static ResponseBody create(MediaType mediaType, ByteString byteString) {
return create(mediaType, byteString.size(), new Buffer().write(byteString));
}
public static ResponseBody create(final MediaType mediaType, final long j, final BufferedSource bufferedSource) {
if (bufferedSource == null) {
throw new NullPointerException("source == null");
}
return new ResponseBody() { // from class: okhttp3.ResponseBody.1
@Override // okhttp3.ResponseBody
public long contentLength() {
return j;
}
@Override // okhttp3.ResponseBody
public MediaType contentType() {
return MediaType.this;
}
@Override // okhttp3.ResponseBody
public BufferedSource source() {
return bufferedSource;
}
};
}
public static final class BomAwareReader extends Reader {
public final Charset charset;
public boolean closed;
public Reader delegate;
public final BufferedSource source;
public BomAwareReader(BufferedSource bufferedSource, Charset charset) {
this.source = bufferedSource;
this.charset = charset;
}
@Override // java.io.Reader
public int read(char[] cArr, int i, int i2) {
if (this.closed) {
throw new IOException("Stream closed");
}
Reader reader = this.delegate;
if (reader == null) {
InputStreamReader inputStreamReader = new InputStreamReader(this.source.inputStream(), Util.bomAwareCharset(this.source, this.charset));
this.delegate = inputStreamReader;
reader = inputStreamReader;
}
return reader.read(cArr, i, i2);
}
@Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable
public void close() {
this.closed = true;
Reader reader = this.delegate;
if (reader != null) {
reader.close();
} else {
this.source.close();
}
}
}
}

View File

@@ -0,0 +1,61 @@
package okhttp3;
import com.ironsource.mediationsdk.logger.IronSourceError;
import java.net.InetSocketAddress;
import java.net.Proxy;
/* loaded from: classes5.dex */
public final class Route {
public final Address address;
public final InetSocketAddress inetSocketAddress;
public final Proxy proxy;
public Address address() {
return this.address;
}
public Proxy proxy() {
return this.proxy;
}
public InetSocketAddress socketAddress() {
return this.inetSocketAddress;
}
public Route(Address address, Proxy proxy, InetSocketAddress inetSocketAddress) {
if (address == null) {
throw new NullPointerException("address == null");
}
if (proxy == null) {
throw new NullPointerException("proxy == null");
}
if (inetSocketAddress == null) {
throw new NullPointerException("inetSocketAddress == null");
}
this.address = address;
this.proxy = proxy;
this.inetSocketAddress = inetSocketAddress;
}
public boolean requiresTunnel() {
return this.address.sslSocketFactory != null && this.proxy.type() == Proxy.Type.HTTP;
}
public boolean equals(Object obj) {
if (obj instanceof Route) {
Route route = (Route) obj;
if (route.address.equals(this.address) && route.proxy.equals(this.proxy) && route.inetSocketAddress.equals(this.inetSocketAddress)) {
return true;
}
}
return false;
}
public int hashCode() {
return ((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.address.hashCode()) * 31) + this.proxy.hashCode()) * 31) + this.inetSocketAddress.hashCode();
}
public String toString() {
return "Route{" + this.inetSocketAddress + "}";
}
}

View File

@@ -0,0 +1,50 @@
package okhttp3;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes5.dex */
public enum TlsVersion {
TLS_1_3("TLSv1.3"),
TLS_1_2("TLSv1.2"),
TLS_1_1("TLSv1.1"),
TLS_1_0("TLSv1"),
SSL_3_0("SSLv3");
final String javaName;
public String javaName() {
return this.javaName;
}
TlsVersion(String str) {
this.javaName = str;
}
public static TlsVersion forJavaName(String str) {
str.hashCode();
switch (str) {
case "TLSv1.1":
return TLS_1_1;
case "TLSv1.2":
return TLS_1_2;
case "TLSv1.3":
return TLS_1_3;
case "SSLv3":
return SSL_3_0;
case "TLSv1":
return TLS_1_0;
default:
throw new IllegalArgumentException("Unexpected TLS version: " + str);
}
}
public static List<TlsVersion> forJavaNames(String... strArr) {
ArrayList arrayList = new ArrayList(strArr.length);
for (String str : strArr) {
arrayList.add(forJavaName(str));
}
return Collections.unmodifiableList(arrayList);
}
}

View File

@@ -0,0 +1,31 @@
package okhttp3.internal;
import javax.net.ssl.SSLSocket;
import okhttp3.Address;
import okhttp3.ConnectionPool;
import okhttp3.ConnectionSpec;
import okhttp3.Headers;
import okhttp3.Response;
import okhttp3.internal.connection.Exchange;
import okhttp3.internal.connection.RealConnectionPool;
/* loaded from: classes5.dex */
public abstract class Internal {
public static Internal instance;
public abstract void addLenient(Headers.Builder builder, String str);
public abstract void addLenient(Headers.Builder builder, String str, String str2);
public abstract void apply(ConnectionSpec connectionSpec, SSLSocket sSLSocket, boolean z);
public abstract int code(Response.Builder builder);
public abstract boolean equalsNonHost(Address address, Address address2);
public abstract Exchange exchange(Response response);
public abstract void initExchange(Response.Builder builder, Exchange exchange);
public abstract RealConnectionPool realConnectionPool(ConnectionPool connectionPool);
}

View File

@@ -0,0 +1,23 @@
package okhttp3.internal;
/* loaded from: classes5.dex */
public abstract class NamedRunnable implements Runnable {
public final String name;
public abstract void execute();
public NamedRunnable(String str, Object... objArr) {
this.name = Util.format(str, objArr);
}
@Override // java.lang.Runnable
public final void run() {
String name = Thread.currentThread().getName();
Thread.currentThread().setName(this.name);
try {
execute();
} finally {
Thread.currentThread().setName(name);
}
}
}

View File

@@ -0,0 +1,659 @@
package okhttp3.internal;
import android.support.v4.media.session.PlaybackStateCompat;
import com.facebook.internal.security.CertificateUtil;
import com.ironsource.v8;
import java.io.Closeable;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.IDN;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.AccessControlException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.util.ArrayList;
import java.util.Arrays;
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 java.util.regex.Pattern;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.internal.http2.Header;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import okio.Options;
import okio.Source;
/* loaded from: classes5.dex */
public abstract class Util {
public static final byte[] EMPTY_BYTE_ARRAY;
public static final RequestBody EMPTY_REQUEST;
public static final ResponseBody EMPTY_RESPONSE;
public static final Pattern VERIFY_AS_IP_ADDRESS;
public static final Method addSuppressedExceptionMethod;
public static final String[] EMPTY_STRING_ARRAY = new String[0];
public static final Headers EMPTY_HEADERS = Headers.of(new String[0]);
public static final Options UNICODE_BOMS = Options.of(ByteString.decodeHex("efbbbf"), ByteString.decodeHex("feff"), ByteString.decodeHex("fffe"), ByteString.decodeHex("0000ffff"), ByteString.decodeHex("ffff0000"));
public static final Charset UTF_32BE = Charset.forName("UTF-32BE");
public static final Charset UTF_32LE = Charset.forName("UTF-32LE");
public static final TimeZone UTC = TimeZone.getTimeZone("GMT");
public static final Comparator NATURAL_ORDER = new Comparator() { // from class: okhttp3.internal.Util$$ExternalSyntheticLambda1
@Override // java.util.Comparator
public final int compare(Object obj, Object obj2) {
return ((String) obj).compareTo((String) obj2);
}
};
public static int decodeHexDigit(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'a' && c <= 'f') {
return c - 'W';
}
if (c < 'A' || c > 'F') {
return -1;
}
return c - '7';
}
static {
byte[] bArr = new byte[0];
EMPTY_BYTE_ARRAY = bArr;
Method method = null;
EMPTY_RESPONSE = ResponseBody.create((MediaType) null, bArr);
EMPTY_REQUEST = RequestBody.create((MediaType) null, bArr);
try {
method = Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class);
} catch (Exception unused) {
}
addSuppressedExceptionMethod = method;
VERIFY_AS_IP_ADDRESS = Pattern.compile("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");
}
public static void addSuppressedIfPossible(Throwable th, Throwable th2) {
Method method = addSuppressedExceptionMethod;
if (method != null) {
try {
method.invoke(th, th2);
} catch (IllegalAccessException | InvocationTargetException unused) {
}
}
}
public static void checkOffsetAndCount(long j, long j2, long j3) {
if ((j2 | j3) < 0 || j2 > j || j - j2 < j3) {
throw new ArrayIndexOutOfBoundsException();
}
}
public static void closeQuietly(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception unused) {
}
}
}
public static void closeQuietly(Socket socket) {
if (socket != null) {
try {
socket.close();
} catch (AssertionError e) {
if (!isAndroidGetsocknameError(e)) {
throw e;
}
} catch (RuntimeException e2) {
throw e2;
} catch (Exception unused) {
}
}
}
public static boolean discard(Source source, int i, TimeUnit timeUnit) {
try {
return skipAll(source, i, timeUnit);
} catch (IOException unused) {
return false;
}
}
public static boolean skipAll(Source source, int i, TimeUnit timeUnit) {
long nanoTime = System.nanoTime();
long deadlineNanoTime = source.timeout().hasDeadline() ? source.timeout().deadlineNanoTime() - nanoTime : Long.MAX_VALUE;
source.timeout().deadlineNanoTime(Math.min(deadlineNanoTime, timeUnit.toNanos(i)) + nanoTime);
try {
Buffer buffer = new Buffer();
while (source.read(buffer, PlaybackStateCompat.ACTION_PLAY_FROM_URI) != -1) {
buffer.clear();
}
if (deadlineNanoTime == Long.MAX_VALUE) {
source.timeout().clearDeadline();
return true;
}
source.timeout().deadlineNanoTime(nanoTime + deadlineNanoTime);
return true;
} catch (InterruptedIOException unused) {
if (deadlineNanoTime == Long.MAX_VALUE) {
source.timeout().clearDeadline();
return false;
}
source.timeout().deadlineNanoTime(nanoTime + deadlineNanoTime);
return false;
} catch (Throwable th) {
if (deadlineNanoTime == Long.MAX_VALUE) {
source.timeout().clearDeadline();
} else {
source.timeout().deadlineNanoTime(nanoTime + deadlineNanoTime);
}
throw th;
}
}
public static List immutableList(List list) {
return Collections.unmodifiableList(new ArrayList(list));
}
public static Map immutableMap(Map map) {
if (map.isEmpty()) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(new LinkedHashMap(map));
}
public static List immutableList(Object... objArr) {
return Collections.unmodifiableList(Arrays.asList((Object[]) objArr.clone()));
}
public static ThreadFactory threadFactory(final String str, final boolean z) {
return new ThreadFactory() { // from class: okhttp3.internal.Util$$ExternalSyntheticLambda0
@Override // java.util.concurrent.ThreadFactory
public final Thread newThread(Runnable runnable) {
Thread lambda$threadFactory$0;
lambda$threadFactory$0 = Util.lambda$threadFactory$0(str, z, runnable);
return lambda$threadFactory$0;
}
};
}
public static /* synthetic */ Thread lambda$threadFactory$0(String str, boolean z, Runnable runnable) {
Thread thread = new Thread(runnable, str);
thread.setDaemon(z);
return thread;
}
public static String[] intersect(Comparator comparator, String[] strArr, String[] strArr2) {
ArrayList arrayList = new ArrayList();
for (String str : strArr) {
int length = strArr2.length;
int i = 0;
while (true) {
if (i >= length) {
break;
}
if (comparator.compare(str, strArr2[i]) == 0) {
arrayList.add(str);
break;
}
i++;
}
}
return (String[]) arrayList.toArray(new String[arrayList.size()]);
}
public static boolean nonEmptyIntersection(Comparator comparator, String[] strArr, String[] strArr2) {
if (strArr != null && strArr2 != null && strArr.length != 0 && strArr2.length != 0) {
for (String str : strArr) {
for (String str2 : strArr2) {
if (comparator.compare(str, str2) == 0) {
return true;
}
}
}
}
return false;
}
public static String hostHeader(HttpUrl httpUrl, boolean z) {
String host;
if (httpUrl.host().contains(CertificateUtil.DELIMITER)) {
host = v8.i.d + httpUrl.host() + v8.i.e;
} else {
host = httpUrl.host();
}
if (!z && httpUrl.port() == HttpUrl.defaultPort(httpUrl.scheme())) {
return host;
}
return host + CertificateUtil.DELIMITER + httpUrl.port();
}
public static boolean isAndroidGetsocknameError(AssertionError assertionError) {
return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true;
}
public static int indexOf(Comparator comparator, String[] strArr, String str) {
int length = strArr.length;
for (int i = 0; i < length; i++) {
if (comparator.compare(strArr[i], str) == 0) {
return i;
}
}
return -1;
}
public static String[] concat(String[] strArr, String str) {
int length = strArr.length;
String[] strArr2 = new String[length + 1];
System.arraycopy(strArr, 0, strArr2, 0, strArr.length);
strArr2[length] = str;
return strArr2;
}
public static int skipLeadingAsciiWhitespace(String str, int i, int i2) {
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 int skipTrailingAsciiWhitespace(String str, int i, int i2) {
for (int i3 = i2 - 1; i3 >= i; i3--) {
char charAt = str.charAt(i3);
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
return i3 + 1;
}
}
return i;
}
public static String trimSubstring(String str, int i, int i2) {
int skipLeadingAsciiWhitespace = skipLeadingAsciiWhitespace(str, i, i2);
return str.substring(skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace(str, skipLeadingAsciiWhitespace, i2));
}
public static int delimiterOffset(String str, int i, int i2, String str2) {
while (i < i2) {
if (str2.indexOf(str.charAt(i)) != -1) {
return i;
}
i++;
}
return i2;
}
public static int delimiterOffset(String str, int i, int i2, char c) {
while (i < i2) {
if (str.charAt(i) == c) {
return i;
}
i++;
}
return i2;
}
public static String canonicalizeHost(String str) {
InetAddress decodeIpv6;
if (str.contains(CertificateUtil.DELIMITER)) {
if (str.startsWith(v8.i.d) && str.endsWith(v8.i.e)) {
decodeIpv6 = decodeIpv6(str, 1, str.length() - 1);
} else {
decodeIpv6 = decodeIpv6(str, 0, str.length());
}
if (decodeIpv6 == null) {
return null;
}
byte[] address = decodeIpv6.getAddress();
if (address.length == 16) {
return inet6AddressToAscii(address);
}
if (address.length == 4) {
return decodeIpv6.getHostAddress();
}
throw new AssertionError("Invalid IPv6 address: '" + str + "'");
}
try {
String lowerCase = IDN.toASCII(str).toLowerCase(Locale.US);
if (lowerCase.isEmpty()) {
return null;
}
if (containsInvalidHostnameAsciiCodes(lowerCase)) {
return null;
}
return lowerCase;
} catch (IllegalArgumentException unused) {
return null;
}
}
public static boolean containsInvalidHostnameAsciiCodes(String str) {
for (int i = 0; i < str.length(); i++) {
char charAt = str.charAt(i);
if (charAt <= 31 || charAt >= 127 || " #%/:?@[\\]".indexOf(charAt) != -1) {
return true;
}
}
return false;
}
public static int indexOfControlOrNonAscii(String str) {
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 boolean verifyAsIpAddress(String str) {
return VERIFY_AS_IP_ADDRESS.matcher(str).matches();
}
public static String format(String str, Object... objArr) {
return String.format(Locale.US, str, objArr);
}
public static Charset bomAwareCharset(BufferedSource bufferedSource, Charset charset) {
int select = bufferedSource.select(UNICODE_BOMS);
if (select == -1) {
return charset;
}
if (select == 0) {
return StandardCharsets.UTF_8;
}
if (select == 1) {
return StandardCharsets.UTF_16BE;
}
if (select == 2) {
return StandardCharsets.UTF_16LE;
}
if (select == 3) {
return UTF_32BE;
}
if (select == 4) {
return UTF_32LE;
}
throw new AssertionError();
}
public static int checkDuration(String str, long j, TimeUnit timeUnit) {
if (j < 0) {
throw new IllegalArgumentException(str + " < 0");
}
if (timeUnit == null) {
throw new NullPointerException("unit == null");
}
long millis = timeUnit.toMillis(j);
if (millis > 2147483647L) {
throw new IllegalArgumentException(str + " too large.");
}
if (millis != 0 || j <= 0) {
return (int) millis;
}
throw new IllegalArgumentException(str + " too small.");
}
/* JADX WARN: Code restructure failed: missing block: B:25:0x0078, code lost:
return null;
*/
/* JADX WARN: Removed duplicated region for block: B:15:0x004f */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static java.net.InetAddress decodeIpv6(java.lang.String r12, int r13, int r14) {
/*
r0 = 16
byte[] r1 = new byte[r0]
r2 = 0
r3 = -1
r4 = r2
r5 = r3
r6 = r5
L9:
r7 = 0
if (r13 >= r14) goto L79
if (r4 != r0) goto Lf
return r7
Lf:
int r8 = r13 + 2
r9 = 2
if (r8 > r14) goto L27
java.lang.String r10 = "::"
boolean r10 = r12.regionMatches(r13, r10, r2, r9)
if (r10 == 0) goto L27
if (r5 == r3) goto L1f
return r7
L1f:
int r4 = r4 + 2
r5 = r4
if (r8 != r14) goto L25
goto L79
L25:
r6 = r8
goto L4b
L27:
if (r4 == 0) goto L34
java.lang.String r8 = ":"
r10 = 1
boolean r8 = r12.regionMatches(r13, r8, r2, r10)
if (r8 == 0) goto L36
int r13 = r13 + 1
L34:
r6 = r13
goto L4b
L36:
java.lang.String r8 = "."
boolean r13 = r12.regionMatches(r13, r8, r2, r10)
if (r13 == 0) goto L4a
int r13 = r4 + (-2)
boolean r12 = decodeIpv4Suffix(r12, r6, r14, r1, r13)
if (r12 != 0) goto L47
return r7
L47:
int r4 = r4 + 2
goto L79
L4a:
return r7
L4b:
r8 = r2
r13 = r6
L4d:
if (r13 >= r14) goto L60
char r10 = r12.charAt(r13)
int r10 = decodeHexDigit(r10)
if (r10 != r3) goto L5a
goto L60
L5a:
int r8 = r8 << 4
int r8 = r8 + r10
int r13 = r13 + 1
goto L4d
L60:
int r10 = r13 - r6
if (r10 == 0) goto L78
r11 = 4
if (r10 <= r11) goto L68
goto L78
L68:
int r7 = r4 + 1
int r10 = r8 >>> 8
r10 = r10 & 255(0xff, float:3.57E-43)
byte r10 = (byte) r10
r1[r4] = r10
int r4 = r4 + r9
r8 = r8 & 255(0xff, float:3.57E-43)
byte r8 = (byte) r8
r1[r7] = r8
goto L9
L78:
return r7
L79:
if (r4 == r0) goto L8a
if (r5 != r3) goto L7e
return r7
L7e:
int r12 = r4 - r5
int r13 = 16 - r12
java.lang.System.arraycopy(r1, r5, r1, r13, r12)
int r0 = r0 - r4
int r0 = r0 + r5
java.util.Arrays.fill(r1, r5, r0, r2)
L8a:
java.net.InetAddress r12 = java.net.InetAddress.getByAddress(r1) // Catch: java.net.UnknownHostException -> L8f
return r12
L8f:
java.lang.AssertionError r12 = new java.lang.AssertionError
r12.<init>()
throw r12
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.Util.decodeIpv6(java.lang.String, int, int):java.net.InetAddress");
}
public static boolean decodeIpv4Suffix(String str, int i, int i2, byte[] bArr, int i3) {
int i4 = i3;
while (i < i2) {
if (i4 == bArr.length) {
return false;
}
if (i4 != i3) {
if (str.charAt(i) != '.') {
return false;
}
i++;
}
int i5 = i;
int i6 = 0;
while (i5 < i2) {
char charAt = str.charAt(i5);
if (charAt < '0' || charAt > '9') {
break;
}
if ((i6 == 0 && i != i5) || (i6 = ((i6 * 10) + charAt) - 48) > 255) {
return false;
}
i5++;
}
if (i5 - i == 0) {
return false;
}
bArr[i4] = (byte) i6;
i4++;
i = i5;
}
return i4 == i3 + 4;
}
public static String inet6AddressToAscii(byte[] bArr) {
int i = -1;
int i2 = 0;
int i3 = 0;
int i4 = 0;
while (i3 < bArr.length) {
int i5 = i3;
while (i5 < 16 && bArr[i5] == 0 && bArr[i5 + 1] == 0) {
i5 += 2;
}
int i6 = i5 - i3;
if (i6 > i4 && i6 >= 4) {
i = i3;
i4 = i6;
}
i3 = i5 + 2;
}
Buffer buffer = new Buffer();
while (i2 < bArr.length) {
if (i2 == i) {
buffer.writeByte(58);
i2 += i4;
if (i2 == 16) {
buffer.writeByte(58);
}
} else {
if (i2 > 0) {
buffer.writeByte(58);
}
buffer.writeHexadecimalUnsignedLong(((bArr[i2] & 255) << 8) | (bArr[i2 + 1] & 255));
i2 += 2;
}
}
return buffer.readUtf8();
}
public static X509TrustManager platformTrustManager() {
try {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore) null);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length == 1) {
TrustManager trustManager = trustManagers[0];
if (trustManager instanceof X509TrustManager) {
return (X509TrustManager) trustManager;
}
}
throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers));
} catch (GeneralSecurityException e) {
throw new AssertionError("No System TLS", e);
}
}
public static Headers toHeaders(List list) {
Headers.Builder builder = new Headers.Builder();
Iterator it = list.iterator();
while (it.hasNext()) {
Header header = (Header) it.next();
Internal.instance.addLenient(builder, header.name.utf8(), header.value.utf8());
}
return builder.build();
}
public static List toHeaderBlock(Headers headers) {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < headers.size(); i++) {
arrayList.add(new Header(headers.name(i), headers.value(i)));
}
return arrayList;
}
public static String getSystemProperty(String str, String str2) {
try {
String property = System.getProperty(str);
return property != null ? property : str2;
} catch (AccessControlException unused) {
return str2;
}
}
public static boolean sameConnection(HttpUrl httpUrl, HttpUrl httpUrl2) {
return httpUrl.host().equals(httpUrl2.host()) && httpUrl.port() == httpUrl2.port() && httpUrl.scheme().equals(httpUrl2.scheme());
}
}

View File

@@ -0,0 +1,8 @@
package okhttp3.internal;
/* loaded from: classes5.dex */
public abstract class Version {
public static String userAgent() {
return "okhttp/3.14.9";
}
}

View File

@@ -0,0 +1,169 @@
package okhttp3.internal.cache;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.cache.CacheStrategy;
import okhttp3.internal.http.HttpHeaders;
import okhttp3.internal.http.HttpMethod;
import okhttp3.internal.http.RealResponseBody;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.Okio;
import okio.Sink;
import okio.Source;
import okio.Timeout;
import org.apache.http.HttpStatus;
import org.apache.http.auth.AUTH;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class CacheInterceptor implements Interceptor {
public final InternalCache cache;
public CacheInterceptor(InternalCache internalCache) {
this.cache = internalCache;
}
@Override // okhttp3.Interceptor
public Response intercept(Interceptor.Chain chain) {
InternalCache internalCache = this.cache;
Response response = internalCache != null ? internalCache.get(chain.request()) : null;
CacheStrategy cacheStrategy = new CacheStrategy.Factory(System.currentTimeMillis(), chain.request(), response).get();
Request request = cacheStrategy.networkRequest;
Response response2 = cacheStrategy.cacheResponse;
InternalCache internalCache2 = this.cache;
if (internalCache2 != null) {
internalCache2.trackResponse(cacheStrategy);
}
if (response != null && response2 == null) {
Util.closeQuietly(response.body());
}
if (request == null && response2 == null) {
return new Response.Builder().request(chain.request()).protocol(Protocol.HTTP_1_1).code(HttpStatus.SC_GATEWAY_TIMEOUT).message("Unsatisfiable Request (only-if-cached)").body(Util.EMPTY_RESPONSE).sentRequestAtMillis(-1L).receivedResponseAtMillis(System.currentTimeMillis()).build();
}
if (request == null) {
return response2.newBuilder().cacheResponse(stripBody(response2)).build();
}
try {
Response proceed = chain.proceed(request);
if (proceed == null && response != null) {
}
if (response2 != null) {
if (proceed.code() == 304) {
Response build = response2.newBuilder().headers(combine(response2.headers(), proceed.headers())).sentRequestAtMillis(proceed.sentRequestAtMillis()).receivedResponseAtMillis(proceed.receivedResponseAtMillis()).cacheResponse(stripBody(response2)).networkResponse(stripBody(proceed)).build();
proceed.body().close();
this.cache.trackConditionalCacheHit();
this.cache.update(response2, build);
return build;
}
Util.closeQuietly(response2.body());
}
Response build2 = proceed.newBuilder().cacheResponse(stripBody(response2)).networkResponse(stripBody(proceed)).build();
if (this.cache != null) {
if (HttpHeaders.hasBody(build2) && CacheStrategy.isCacheable(build2, request)) {
return cacheWritingResponse(this.cache.put(build2), build2);
}
if (HttpMethod.invalidatesCache(request.method())) {
try {
this.cache.remove(request);
} catch (IOException unused) {
}
}
}
return build2;
} finally {
if (response != null) {
Util.closeQuietly(response.body());
}
}
}
public static Response stripBody(Response response) {
return (response == null || response.body() == null) ? response : response.newBuilder().body(null).build();
}
public final Response cacheWritingResponse(final CacheRequest cacheRequest, Response response) {
Sink body;
if (cacheRequest == null || (body = cacheRequest.body()) == null) {
return response;
}
final BufferedSource source = response.body().source();
final BufferedSink buffer = Okio.buffer(body);
return response.newBuilder().body(new RealResponseBody(response.header("Content-Type"), response.body().contentLength(), Okio.buffer(new Source() { // from class: okhttp3.internal.cache.CacheInterceptor.1
public boolean cacheRequestClosed;
@Override // okio.Source
public long read(Buffer buffer2, long j) {
try {
long read = source.read(buffer2, j);
if (read != -1) {
buffer2.copyTo(buffer.buffer(), buffer2.size() - read, read);
buffer.emitCompleteSegments();
return read;
}
if (!this.cacheRequestClosed) {
this.cacheRequestClosed = true;
buffer.close();
}
return -1L;
} catch (IOException e) {
if (!this.cacheRequestClosed) {
this.cacheRequestClosed = true;
cacheRequest.abort();
}
throw e;
}
}
@Override // okio.Source
public Timeout timeout() {
return source.timeout();
}
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (!this.cacheRequestClosed && !Util.discard(this, 100, TimeUnit.MILLISECONDS)) {
this.cacheRequestClosed = true;
cacheRequest.abort();
}
source.close();
}
}))).build();
}
public static Headers combine(Headers headers, Headers headers2) {
Headers.Builder builder = new Headers.Builder();
int size = headers.size();
for (int i = 0; i < size; i++) {
String name = headers.name(i);
String value = headers.value(i);
if ((!"Warning".equalsIgnoreCase(name) || !value.startsWith("1")) && (isContentSpecificHeader(name) || !isEndToEnd(name) || headers2.get(name) == null)) {
Internal.instance.addLenient(builder, name, value);
}
}
int size2 = headers2.size();
for (int i2 = 0; i2 < size2; i2++) {
String name2 = headers2.name(i2);
if (!isContentSpecificHeader(name2) && isEndToEnd(name2)) {
Internal.instance.addLenient(builder, name2, headers2.value(i2));
}
}
return builder.build();
}
public static boolean isEndToEnd(String str) {
return (HTTP.CONN_DIRECTIVE.equalsIgnoreCase(str) || HTTP.CONN_KEEP_ALIVE.equalsIgnoreCase(str) || AUTH.PROXY_AUTH.equalsIgnoreCase(str) || AUTH.PROXY_AUTH_RESP.equalsIgnoreCase(str) || "TE".equalsIgnoreCase(str) || "Trailers".equalsIgnoreCase(str) || HTTP.TRANSFER_ENCODING.equalsIgnoreCase(str) || "Upgrade".equalsIgnoreCase(str)) ? false : true;
}
public static boolean isContentSpecificHeader(String str) {
return HTTP.CONTENT_LEN.equalsIgnoreCase(str) || HTTP.CONTENT_ENCODING.equalsIgnoreCase(str) || "Content-Type".equalsIgnoreCase(str);
}
}

View File

@@ -0,0 +1,10 @@
package okhttp3.internal.cache;
import okio.Sink;
/* loaded from: classes5.dex */
public interface CacheRequest {
void abort();
Sink body();
}

View File

@@ -0,0 +1,246 @@
package okhttp3.internal.cache;
import com.mbridge.msdk.foundation.download.Command;
import com.vungle.ads.internal.signals.SignalManager;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import okhttp3.CacheControl;
import okhttp3.Headers;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Internal;
import okhttp3.internal.http.HttpDate;
import okhttp3.internal.http.HttpHeaders;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class CacheStrategy {
public final Response cacheResponse;
public final Request networkRequest;
public CacheStrategy(Request request, Response response) {
this.networkRequest = request;
this.cacheResponse = response;
}
/* JADX WARN: Code restructure failed: missing block: B:31:0x0056, code lost:
if (r3.cacheControl().isPrivate() == false) goto L33;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static boolean isCacheable(okhttp3.Response r3, okhttp3.Request r4) {
/*
int r0 = r3.code()
r1 = 200(0xc8, float:2.8E-43)
r2 = 0
if (r0 == r1) goto L5a
r1 = 410(0x19a, float:5.75E-43)
if (r0 == r1) goto L5a
r1 = 414(0x19e, float:5.8E-43)
if (r0 == r1) goto L5a
r1 = 501(0x1f5, float:7.02E-43)
if (r0 == r1) goto L5a
r1 = 203(0xcb, float:2.84E-43)
if (r0 == r1) goto L5a
r1 = 204(0xcc, float:2.86E-43)
if (r0 == r1) goto L5a
r1 = 307(0x133, float:4.3E-43)
if (r0 == r1) goto L31
r1 = 308(0x134, float:4.32E-43)
if (r0 == r1) goto L5a
r1 = 404(0x194, float:5.66E-43)
if (r0 == r1) goto L5a
r1 = 405(0x195, float:5.68E-43)
if (r0 == r1) goto L5a
switch(r0) {
case 300: goto L5a;
case 301: goto L5a;
case 302: goto L31;
default: goto L30;
}
L30:
goto L59
L31:
java.lang.String r0 = "Expires"
java.lang.String r0 = r3.header(r0)
if (r0 != 0) goto L5a
okhttp3.CacheControl r0 = r3.cacheControl()
int r0 = r0.maxAgeSeconds()
r1 = -1
if (r0 != r1) goto L5a
okhttp3.CacheControl r0 = r3.cacheControl()
boolean r0 = r0.isPublic()
if (r0 != 0) goto L5a
okhttp3.CacheControl r0 = r3.cacheControl()
boolean r0 = r0.isPrivate()
if (r0 == 0) goto L59
goto L5a
L59:
return r2
L5a:
okhttp3.CacheControl r3 = r3.cacheControl()
boolean r3 = r3.noStore()
if (r3 != 0) goto L6f
okhttp3.CacheControl r3 = r4.cacheControl()
boolean r3 = r3.noStore()
if (r3 != 0) goto L6f
r2 = 1
L6f:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.cache.CacheStrategy.isCacheable(okhttp3.Response, okhttp3.Request):boolean");
}
public static class Factory {
public int ageSeconds;
public final Response cacheResponse;
public String etag;
public Date expires;
public Date lastModified;
public String lastModifiedString;
public final long nowMillis;
public long receivedResponseMillis;
public final Request request;
public long sentRequestMillis;
public Date servedDate;
public String servedDateString;
public Factory(long j, Request request, Response response) {
this.ageSeconds = -1;
this.nowMillis = j;
this.request = request;
this.cacheResponse = response;
if (response != null) {
this.sentRequestMillis = response.sentRequestAtMillis();
this.receivedResponseMillis = response.receivedResponseAtMillis();
Headers headers = response.headers();
int size = headers.size();
for (int i = 0; i < size; i++) {
String name = headers.name(i);
String value = headers.value(i);
if (HTTP.DATE_HEADER.equalsIgnoreCase(name)) {
this.servedDate = HttpDate.parse(value);
this.servedDateString = value;
} else if ("Expires".equalsIgnoreCase(name)) {
this.expires = HttpDate.parse(value);
} else if ("Last-Modified".equalsIgnoreCase(name)) {
this.lastModified = HttpDate.parse(value);
this.lastModifiedString = value;
} else if (Command.HTTP_HEADER_ETAG.equalsIgnoreCase(name)) {
this.etag = value;
} else if ("Age".equalsIgnoreCase(name)) {
this.ageSeconds = HttpHeaders.parseSeconds(value, -1);
}
}
}
}
public CacheStrategy get() {
CacheStrategy candidate = getCandidate();
return (candidate.networkRequest == null || !this.request.cacheControl().onlyIfCached()) ? candidate : new CacheStrategy(null, null);
}
public final CacheStrategy getCandidate() {
String str;
if (this.cacheResponse == null) {
return new CacheStrategy(this.request, null);
}
if (this.request.isHttps() && this.cacheResponse.handshake() == null) {
return new CacheStrategy(this.request, null);
}
if (!CacheStrategy.isCacheable(this.cacheResponse, this.request)) {
return new CacheStrategy(this.request, null);
}
CacheControl cacheControl = this.request.cacheControl();
if (cacheControl.noCache() || hasConditions(this.request)) {
return new CacheStrategy(this.request, null);
}
CacheControl cacheControl2 = this.cacheResponse.cacheControl();
long cacheResponseAge = cacheResponseAge();
long computeFreshnessLifetime = computeFreshnessLifetime();
if (cacheControl.maxAgeSeconds() != -1) {
computeFreshnessLifetime = Math.min(computeFreshnessLifetime, TimeUnit.SECONDS.toMillis(cacheControl.maxAgeSeconds()));
}
long j = 0;
long millis = cacheControl.minFreshSeconds() != -1 ? TimeUnit.SECONDS.toMillis(cacheControl.minFreshSeconds()) : 0L;
if (!cacheControl2.mustRevalidate() && cacheControl.maxStaleSeconds() != -1) {
j = TimeUnit.SECONDS.toMillis(cacheControl.maxStaleSeconds());
}
if (!cacheControl2.noCache()) {
long j2 = millis + cacheResponseAge;
if (j2 < j + computeFreshnessLifetime) {
Response.Builder newBuilder = this.cacheResponse.newBuilder();
if (j2 >= computeFreshnessLifetime) {
newBuilder.addHeader("Warning", "110 HttpURLConnection \"Response is stale\"");
}
if (cacheResponseAge > SignalManager.TWENTY_FOUR_HOURS_MILLIS && isFreshnessLifetimeHeuristic()) {
newBuilder.addHeader("Warning", "113 HttpURLConnection \"Heuristic expiration\"");
}
return new CacheStrategy(null, newBuilder.build());
}
}
String str2 = this.etag;
if (str2 != null) {
str = "If-None-Match";
} else {
if (this.lastModified != null) {
str2 = this.lastModifiedString;
} else {
if (this.servedDate == null) {
return new CacheStrategy(this.request, null);
}
str2 = this.servedDateString;
}
str = "If-Modified-Since";
}
Headers.Builder newBuilder2 = this.request.headers().newBuilder();
Internal.instance.addLenient(newBuilder2, str, str2);
return new CacheStrategy(this.request.newBuilder().headers(newBuilder2.build()).build(), this.cacheResponse);
}
public final long computeFreshnessLifetime() {
if (this.cacheResponse.cacheControl().maxAgeSeconds() != -1) {
return TimeUnit.SECONDS.toMillis(r0.maxAgeSeconds());
}
if (this.expires != null) {
Date date = this.servedDate;
long time = this.expires.getTime() - (date != null ? date.getTime() : this.receivedResponseMillis);
if (time > 0) {
return time;
}
return 0L;
}
if (this.lastModified == null || this.cacheResponse.request().url().query() != null) {
return 0L;
}
Date date2 = this.servedDate;
long time2 = (date2 != null ? date2.getTime() : this.sentRequestMillis) - this.lastModified.getTime();
if (time2 > 0) {
return time2 / 10;
}
return 0L;
}
public final long cacheResponseAge() {
Date date = this.servedDate;
long max = date != null ? Math.max(0L, this.receivedResponseMillis - date.getTime()) : 0L;
int i = this.ageSeconds;
if (i != -1) {
max = Math.max(max, TimeUnit.SECONDS.toMillis(i));
}
long j = this.receivedResponseMillis;
return max + (j - this.sentRequestMillis) + (this.nowMillis - j);
}
public final boolean isFreshnessLifetimeHeuristic() {
return this.cacheResponse.cacheControl().maxAgeSeconds() == -1 && this.expires == null;
}
public static boolean hasConditions(Request request) {
return (request.header("If-Modified-Since") == null && request.header("If-None-Match") == null) ? false : true;
}
}
}

View File

@@ -0,0 +1,710 @@
package okhttp3.internal.cache;
import com.ironsource.v8;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.Flushable;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import okhttp3.internal.Util;
import okhttp3.internal.io.FileSystem;
import okhttp3.internal.platform.Platform;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.Okio;
import okio.Sink;
import okio.Source;
/* loaded from: classes5.dex */
public final class DiskLruCache implements Closeable, Flushable {
public static final Pattern LEGAL_KEY_PATTERN = Pattern.compile("[a-z0-9_-]{1,120}");
public final int appVersion;
public boolean closed;
public final File directory;
public final Executor executor;
public final FileSystem fileSystem;
public boolean hasJournalErrors;
public boolean initialized;
public final File journalFile;
public final File journalFileBackup;
public final File journalFileTmp;
public BufferedSink journalWriter;
public long maxSize;
public boolean mostRecentRebuildFailed;
public boolean mostRecentTrimFailed;
public int redundantOpCount;
public final int valueCount;
public long size = 0;
public final LinkedHashMap lruEntries = new LinkedHashMap(0, 0.75f, true);
public long nextSequenceNumber = 0;
public final Runnable cleanupRunnable = new Runnable() { // from class: okhttp3.internal.cache.DiskLruCache.1
@Override // java.lang.Runnable
public void run() {
synchronized (DiskLruCache.this) {
DiskLruCache diskLruCache = DiskLruCache.this;
if ((!diskLruCache.initialized) || diskLruCache.closed) {
return;
}
try {
diskLruCache.trimToSize();
} catch (IOException unused) {
DiskLruCache.this.mostRecentTrimFailed = true;
}
try {
if (DiskLruCache.this.journalRebuildRequired()) {
DiskLruCache.this.rebuildJournal();
DiskLruCache.this.redundantOpCount = 0;
}
} catch (IOException unused2) {
DiskLruCache diskLruCache2 = DiskLruCache.this;
diskLruCache2.mostRecentRebuildFailed = true;
diskLruCache2.journalWriter = Okio.buffer(Okio.blackhole());
}
}
}
};
public DiskLruCache(FileSystem fileSystem, File file, int i, int i2, long j, Executor executor) {
this.fileSystem = fileSystem;
this.directory = file;
this.appVersion = i;
this.journalFile = new File(file, "journal");
this.journalFileTmp = new File(file, "journal.tmp");
this.journalFileBackup = new File(file, "journal.bkp");
this.valueCount = i2;
this.maxSize = j;
this.executor = executor;
}
public synchronized void initialize() {
try {
if (this.initialized) {
return;
}
if (this.fileSystem.exists(this.journalFileBackup)) {
if (this.fileSystem.exists(this.journalFile)) {
this.fileSystem.delete(this.journalFileBackup);
} else {
this.fileSystem.rename(this.journalFileBackup, this.journalFile);
}
}
if (this.fileSystem.exists(this.journalFile)) {
try {
readJournal();
processJournal();
this.initialized = true;
return;
} catch (IOException e) {
Platform.get().log(5, "DiskLruCache " + this.directory + " is corrupt: " + e.getMessage() + ", removing", e);
try {
delete();
this.closed = false;
} catch (Throwable th) {
this.closed = false;
throw th;
}
}
}
rebuildJournal();
this.initialized = true;
} catch (Throwable th2) {
throw th2;
}
}
public static DiskLruCache create(FileSystem fileSystem, File file, int i, int i2, long j) {
if (j <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
if (i2 <= 0) {
throw new IllegalArgumentException("valueCount <= 0");
}
return new DiskLruCache(fileSystem, file, i, i2, j, new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue(), Util.threadFactory("OkHttp DiskLruCache", true)));
}
public final void readJournal() {
BufferedSource buffer = Okio.buffer(this.fileSystem.source(this.journalFile));
try {
String readUtf8LineStrict = buffer.readUtf8LineStrict();
String readUtf8LineStrict2 = buffer.readUtf8LineStrict();
String readUtf8LineStrict3 = buffer.readUtf8LineStrict();
String readUtf8LineStrict4 = buffer.readUtf8LineStrict();
String readUtf8LineStrict5 = buffer.readUtf8LineStrict();
if (!"libcore.io.DiskLruCache".equals(readUtf8LineStrict) || !"1".equals(readUtf8LineStrict2) || !Integer.toString(this.appVersion).equals(readUtf8LineStrict3) || !Integer.toString(this.valueCount).equals(readUtf8LineStrict4) || !"".equals(readUtf8LineStrict5)) {
throw new IOException("unexpected journal header: [" + readUtf8LineStrict + ", " + readUtf8LineStrict2 + ", " + readUtf8LineStrict4 + ", " + readUtf8LineStrict5 + v8.i.e);
}
int i = 0;
while (true) {
try {
readJournalLine(buffer.readUtf8LineStrict());
i++;
} catch (EOFException unused) {
this.redundantOpCount = i - this.lruEntries.size();
if (!buffer.exhausted()) {
rebuildJournal();
} else {
this.journalWriter = newJournalWriter();
}
$closeResource(null, buffer);
return;
}
}
} finally {
}
}
public static /* synthetic */ void $closeResource(Throwable th, AutoCloseable autoCloseable) {
if (th == null) {
autoCloseable.close();
return;
}
try {
autoCloseable.close();
} catch (Throwable th2) {
th.addSuppressed(th2);
}
}
public final BufferedSink newJournalWriter() {
return Okio.buffer(new FaultHidingSink(this.fileSystem.appendingSink(this.journalFile)) { // from class: okhttp3.internal.cache.DiskLruCache.2
@Override // okhttp3.internal.cache.FaultHidingSink
public void onException(IOException iOException) {
DiskLruCache.this.hasJournalErrors = true;
}
});
}
public final void readJournalLine(String str) {
String substring;
int indexOf = str.indexOf(32);
if (indexOf == -1) {
throw new IOException("unexpected journal line: " + str);
}
int i = indexOf + 1;
int indexOf2 = str.indexOf(32, i);
if (indexOf2 == -1) {
substring = str.substring(i);
if (indexOf == 6 && str.startsWith("REMOVE")) {
this.lruEntries.remove(substring);
return;
}
} else {
substring = str.substring(i, indexOf2);
}
Entry entry = (Entry) this.lruEntries.get(substring);
if (entry == null) {
entry = new Entry(substring);
this.lruEntries.put(substring, entry);
}
if (indexOf2 != -1 && indexOf == 5 && str.startsWith("CLEAN")) {
String[] split = str.substring(indexOf2 + 1).split(" ");
entry.readable = true;
entry.currentEditor = null;
entry.setLengths(split);
return;
}
if (indexOf2 == -1 && indexOf == 5 && str.startsWith("DIRTY")) {
entry.currentEditor = new Editor(entry);
return;
}
if (indexOf2 == -1 && indexOf == 4 && str.startsWith("READ")) {
return;
}
throw new IOException("unexpected journal line: " + str);
}
public final void processJournal() {
this.fileSystem.delete(this.journalFileTmp);
Iterator it = this.lruEntries.values().iterator();
while (it.hasNext()) {
Entry entry = (Entry) it.next();
int i = 0;
if (entry.currentEditor == null) {
while (i < this.valueCount) {
this.size += entry.lengths[i];
i++;
}
} else {
entry.currentEditor = null;
while (i < this.valueCount) {
this.fileSystem.delete(entry.cleanFiles[i]);
this.fileSystem.delete(entry.dirtyFiles[i]);
i++;
}
it.remove();
}
}
}
public synchronized void rebuildJournal() {
try {
BufferedSink bufferedSink = this.journalWriter;
if (bufferedSink != null) {
bufferedSink.close();
}
BufferedSink buffer = Okio.buffer(this.fileSystem.sink(this.journalFileTmp));
try {
buffer.writeUtf8("libcore.io.DiskLruCache").writeByte(10);
buffer.writeUtf8("1").writeByte(10);
buffer.writeDecimalLong(this.appVersion).writeByte(10);
buffer.writeDecimalLong(this.valueCount).writeByte(10);
buffer.writeByte(10);
for (Entry entry : this.lruEntries.values()) {
if (entry.currentEditor != null) {
buffer.writeUtf8("DIRTY").writeByte(32);
buffer.writeUtf8(entry.key);
buffer.writeByte(10);
} else {
buffer.writeUtf8("CLEAN").writeByte(32);
buffer.writeUtf8(entry.key);
entry.writeLengths(buffer);
buffer.writeByte(10);
}
}
$closeResource(null, buffer);
if (this.fileSystem.exists(this.journalFile)) {
this.fileSystem.rename(this.journalFile, this.journalFileBackup);
}
this.fileSystem.rename(this.journalFileTmp, this.journalFile);
this.fileSystem.delete(this.journalFileBackup);
this.journalWriter = newJournalWriter();
this.hasJournalErrors = false;
this.mostRecentRebuildFailed = false;
} finally {
}
} catch (Throwable th) {
throw th;
}
}
public synchronized Snapshot get(String str) {
initialize();
checkNotClosed();
validateKey(str);
Entry entry = (Entry) this.lruEntries.get(str);
if (entry != null && entry.readable) {
Snapshot snapshot = entry.snapshot();
if (snapshot == null) {
return null;
}
this.redundantOpCount++;
this.journalWriter.writeUtf8("READ").writeByte(32).writeUtf8(str).writeByte(10);
if (journalRebuildRequired()) {
this.executor.execute(this.cleanupRunnable);
}
return snapshot;
}
return null;
}
public Editor edit(String str) {
return edit(str, -1L);
}
public synchronized Editor edit(String str, long j) {
initialize();
checkNotClosed();
validateKey(str);
Entry entry = (Entry) this.lruEntries.get(str);
if (j != -1 && (entry == null || entry.sequenceNumber != j)) {
return null;
}
if (entry != null && entry.currentEditor != null) {
return null;
}
if (!this.mostRecentTrimFailed && !this.mostRecentRebuildFailed) {
this.journalWriter.writeUtf8("DIRTY").writeByte(32).writeUtf8(str).writeByte(10);
this.journalWriter.flush();
if (this.hasJournalErrors) {
return null;
}
if (entry == null) {
entry = new Entry(str);
this.lruEntries.put(str, entry);
}
Editor editor = new Editor(entry);
entry.currentEditor = editor;
return editor;
}
this.executor.execute(this.cleanupRunnable);
return null;
}
public synchronized void completeEdit(Editor editor, boolean z) {
Entry entry = editor.entry;
if (entry.currentEditor != editor) {
throw new IllegalStateException();
}
if (z && !entry.readable) {
for (int i = 0; i < this.valueCount; i++) {
if (!editor.written[i]) {
editor.abort();
throw new IllegalStateException("Newly created entry didn't create value for index " + i);
}
if (!this.fileSystem.exists(entry.dirtyFiles[i])) {
editor.abort();
return;
}
}
}
for (int i2 = 0; i2 < this.valueCount; i2++) {
File file = entry.dirtyFiles[i2];
if (z) {
if (this.fileSystem.exists(file)) {
File file2 = entry.cleanFiles[i2];
this.fileSystem.rename(file, file2);
long j = entry.lengths[i2];
long size = this.fileSystem.size(file2);
entry.lengths[i2] = size;
this.size = (this.size - j) + size;
}
} else {
this.fileSystem.delete(file);
}
}
this.redundantOpCount++;
entry.currentEditor = null;
if (entry.readable | z) {
entry.readable = true;
this.journalWriter.writeUtf8("CLEAN").writeByte(32);
this.journalWriter.writeUtf8(entry.key);
entry.writeLengths(this.journalWriter);
this.journalWriter.writeByte(10);
if (z) {
long j2 = this.nextSequenceNumber;
this.nextSequenceNumber = 1 + j2;
entry.sequenceNumber = j2;
}
} else {
this.lruEntries.remove(entry.key);
this.journalWriter.writeUtf8("REMOVE").writeByte(32);
this.journalWriter.writeUtf8(entry.key);
this.journalWriter.writeByte(10);
}
this.journalWriter.flush();
if (this.size > this.maxSize || journalRebuildRequired()) {
this.executor.execute(this.cleanupRunnable);
}
}
public boolean journalRebuildRequired() {
int i = this.redundantOpCount;
return i >= 2000 && i >= this.lruEntries.size();
}
public synchronized boolean remove(String str) {
initialize();
checkNotClosed();
validateKey(str);
Entry entry = (Entry) this.lruEntries.get(str);
if (entry == null) {
return false;
}
boolean removeEntry = removeEntry(entry);
if (removeEntry && this.size <= this.maxSize) {
this.mostRecentTrimFailed = false;
}
return removeEntry;
}
public boolean removeEntry(Entry entry) {
Editor editor = entry.currentEditor;
if (editor != null) {
editor.detach();
}
for (int i = 0; i < this.valueCount; i++) {
this.fileSystem.delete(entry.cleanFiles[i]);
long j = this.size;
long[] jArr = entry.lengths;
this.size = j - jArr[i];
jArr[i] = 0;
}
this.redundantOpCount++;
this.journalWriter.writeUtf8("REMOVE").writeByte(32).writeUtf8(entry.key).writeByte(10);
this.lruEntries.remove(entry.key);
if (journalRebuildRequired()) {
this.executor.execute(this.cleanupRunnable);
}
return true;
}
public synchronized boolean isClosed() {
return this.closed;
}
public final synchronized void checkNotClosed() {
if (isClosed()) {
throw new IllegalStateException("cache is closed");
}
}
@Override // java.io.Flushable
public synchronized void flush() {
if (this.initialized) {
checkNotClosed();
trimToSize();
this.journalWriter.flush();
}
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public synchronized void close() {
try {
if (this.initialized && !this.closed) {
for (Entry entry : (Entry[]) this.lruEntries.values().toArray(new Entry[this.lruEntries.size()])) {
Editor editor = entry.currentEditor;
if (editor != null) {
editor.abort();
}
}
trimToSize();
this.journalWriter.close();
this.journalWriter = null;
this.closed = true;
return;
}
this.closed = true;
} catch (Throwable th) {
throw th;
}
}
public void trimToSize() {
while (this.size > this.maxSize) {
removeEntry((Entry) this.lruEntries.values().iterator().next());
}
this.mostRecentTrimFailed = false;
}
public void delete() {
close();
this.fileSystem.deleteContents(this.directory);
}
public final void validateKey(String str) {
if (LEGAL_KEY_PATTERN.matcher(str).matches()) {
return;
}
throw new IllegalArgumentException("keys must match regex [a-z0-9_-]{1,120}: \"" + str + "\"");
}
public final class Snapshot implements Closeable {
public final String key;
public final long[] lengths;
public final long sequenceNumber;
public final Source[] sources;
public Snapshot(String str, long j, Source[] sourceArr, long[] jArr) {
this.key = str;
this.sequenceNumber = j;
this.sources = sourceArr;
this.lengths = jArr;
}
public Editor edit() {
return DiskLruCache.this.edit(this.key, this.sequenceNumber);
}
public Source getSource(int i) {
return this.sources[i];
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() {
for (Source source : this.sources) {
Util.closeQuietly(source);
}
}
}
public final class Editor {
public boolean done;
public final Entry entry;
public final boolean[] written;
public Editor(Entry entry) {
this.entry = entry;
this.written = entry.readable ? null : new boolean[DiskLruCache.this.valueCount];
}
public void detach() {
if (this.entry.currentEditor != this) {
return;
}
int i = 0;
while (true) {
DiskLruCache diskLruCache = DiskLruCache.this;
if (i < diskLruCache.valueCount) {
try {
diskLruCache.fileSystem.delete(this.entry.dirtyFiles[i]);
} catch (IOException unused) {
}
i++;
} else {
this.entry.currentEditor = null;
return;
}
}
}
public Sink newSink(int i) {
synchronized (DiskLruCache.this) {
try {
if (this.done) {
throw new IllegalStateException();
}
Entry entry = this.entry;
if (entry.currentEditor != this) {
return Okio.blackhole();
}
if (!entry.readable) {
this.written[i] = true;
}
try {
return new FaultHidingSink(DiskLruCache.this.fileSystem.sink(entry.dirtyFiles[i])) { // from class: okhttp3.internal.cache.DiskLruCache.Editor.1
@Override // okhttp3.internal.cache.FaultHidingSink
public void onException(IOException iOException) {
synchronized (DiskLruCache.this) {
Editor.this.detach();
}
}
};
} catch (FileNotFoundException unused) {
return Okio.blackhole();
}
} catch (Throwable th) {
throw th;
}
}
}
public void commit() {
synchronized (DiskLruCache.this) {
try {
if (this.done) {
throw new IllegalStateException();
}
if (this.entry.currentEditor == this) {
DiskLruCache.this.completeEdit(this, true);
}
this.done = true;
} catch (Throwable th) {
throw th;
}
}
}
public void abort() {
synchronized (DiskLruCache.this) {
try {
if (this.done) {
throw new IllegalStateException();
}
if (this.entry.currentEditor == this) {
DiskLruCache.this.completeEdit(this, false);
}
this.done = true;
} catch (Throwable th) {
throw th;
}
}
}
}
public final class Entry {
public final File[] cleanFiles;
public Editor currentEditor;
public final File[] dirtyFiles;
public final String key;
public final long[] lengths;
public boolean readable;
public long sequenceNumber;
public Entry(String str) {
this.key = str;
int i = DiskLruCache.this.valueCount;
this.lengths = new long[i];
this.cleanFiles = new File[i];
this.dirtyFiles = new File[i];
StringBuilder sb = new StringBuilder(str);
sb.append('.');
int length = sb.length();
for (int i2 = 0; i2 < DiskLruCache.this.valueCount; i2++) {
sb.append(i2);
this.cleanFiles[i2] = new File(DiskLruCache.this.directory, sb.toString());
sb.append(".tmp");
this.dirtyFiles[i2] = new File(DiskLruCache.this.directory, sb.toString());
sb.setLength(length);
}
}
public void setLengths(String[] strArr) {
if (strArr.length != DiskLruCache.this.valueCount) {
throw invalidLengths(strArr);
}
for (int i = 0; i < strArr.length; i++) {
try {
this.lengths[i] = Long.parseLong(strArr[i]);
} catch (NumberFormatException unused) {
throw invalidLengths(strArr);
}
}
}
public void writeLengths(BufferedSink bufferedSink) {
for (long j : this.lengths) {
bufferedSink.writeByte(32).writeDecimalLong(j);
}
}
public final IOException invalidLengths(String[] strArr) {
throw new IOException("unexpected journal line: " + Arrays.toString(strArr));
}
public Snapshot snapshot() {
Source source;
if (!Thread.holdsLock(DiskLruCache.this)) {
throw new AssertionError();
}
Source[] sourceArr = new Source[DiskLruCache.this.valueCount];
long[] jArr = (long[]) this.lengths.clone();
int i = 0;
int i2 = 0;
while (true) {
try {
DiskLruCache diskLruCache = DiskLruCache.this;
if (i2 < diskLruCache.valueCount) {
sourceArr[i2] = diskLruCache.fileSystem.source(this.cleanFiles[i2]);
i2++;
} else {
return diskLruCache.new Snapshot(this.key, this.sequenceNumber, sourceArr, jArr);
}
} catch (FileNotFoundException unused) {
while (true) {
DiskLruCache diskLruCache2 = DiskLruCache.this;
if (i < diskLruCache2.valueCount && (source = sourceArr[i]) != null) {
Util.closeQuietly(source);
i++;
} else {
try {
diskLruCache2.removeEntry(this);
return null;
} catch (IOException unused2) {
return null;
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,57 @@
package okhttp3.internal.cache;
import java.io.IOException;
import okio.Buffer;
import okio.ForwardingSink;
import okio.Sink;
/* loaded from: classes5.dex */
public abstract class FaultHidingSink extends ForwardingSink {
public boolean hasErrors;
public abstract void onException(IOException iOException);
public FaultHidingSink(Sink sink) {
super(sink);
}
@Override // okio.ForwardingSink, okio.Sink
public void write(Buffer buffer, long j) {
if (this.hasErrors) {
buffer.skip(j);
return;
}
try {
super.write(buffer, j);
} catch (IOException e) {
this.hasErrors = true;
onException(e);
}
}
@Override // okio.ForwardingSink, okio.Sink, java.io.Flushable
public void flush() {
if (this.hasErrors) {
return;
}
try {
super.flush();
} catch (IOException e) {
this.hasErrors = true;
onException(e);
}
}
@Override // okio.ForwardingSink, okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.hasErrors) {
return;
}
try {
super.close();
} catch (IOException e) {
this.hasErrors = true;
onException(e);
}
}
}

View File

@@ -0,0 +1,19 @@
package okhttp3.internal.cache;
import okhttp3.Request;
import okhttp3.Response;
/* loaded from: classes5.dex */
public interface InternalCache {
Response get(Request request);
CacheRequest put(Response response);
void remove(Request request);
void trackConditionalCacheHit();
void trackResponse(CacheStrategy cacheStrategy);
void update(Response response, Response response2);
}

View File

@@ -0,0 +1,24 @@
package okhttp3.internal.connection;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.http.RealInterceptorChain;
/* loaded from: classes5.dex */
public final class ConnectInterceptor implements Interceptor {
public final OkHttpClient client;
public ConnectInterceptor(OkHttpClient okHttpClient) {
this.client = okHttpClient;
}
@Override // okhttp3.Interceptor
public Response intercept(Interceptor.Chain chain) {
RealInterceptorChain realInterceptorChain = (RealInterceptorChain) chain;
Request request = realInterceptorChain.request();
Transmitter transmitter = realInterceptorChain.transmitter();
return realInterceptorChain.proceed(request, transmitter, transmitter.newExchange(chain, !request.method().equals("GET")));
}
}

View File

@@ -0,0 +1,71 @@
package okhttp3.internal.connection;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ProtocolException;
import java.net.UnknownServiceException;
import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocket;
import okhttp3.ConnectionSpec;
import okhttp3.internal.Internal;
/* loaded from: classes5.dex */
public final class ConnectionSpecSelector {
public final List connectionSpecs;
public boolean isFallback;
public boolean isFallbackPossible;
public int nextModeIndex = 0;
public ConnectionSpecSelector(List list) {
this.connectionSpecs = list;
}
public ConnectionSpec configureSecureSocket(SSLSocket sSLSocket) {
ConnectionSpec connectionSpec;
int i = this.nextModeIndex;
int size = this.connectionSpecs.size();
while (true) {
if (i >= size) {
connectionSpec = null;
break;
}
connectionSpec = (ConnectionSpec) this.connectionSpecs.get(i);
if (connectionSpec.isCompatible(sSLSocket)) {
this.nextModeIndex = i + 1;
break;
}
i++;
}
if (connectionSpec == null) {
throw new UnknownServiceException("Unable to find acceptable protocols. isFallback=" + this.isFallback + ", modes=" + this.connectionSpecs + ", supported protocols=" + Arrays.toString(sSLSocket.getEnabledProtocols()));
}
this.isFallbackPossible = isFallbackPossible(sSLSocket);
Internal.instance.apply(connectionSpec, sSLSocket, this.isFallback);
return connectionSpec;
}
public boolean connectionFailed(IOException iOException) {
this.isFallback = true;
if (!this.isFallbackPossible || (iOException instanceof ProtocolException) || (iOException instanceof InterruptedIOException)) {
return false;
}
if (((iOException instanceof SSLHandshakeException) && (iOException.getCause() instanceof CertificateException)) || (iOException instanceof SSLPeerUnverifiedException)) {
return false;
}
return iOException instanceof SSLException;
}
public final boolean isFallbackPossible(SSLSocket sSLSocket) {
for (int i = this.nextModeIndex; i < this.connectionSpecs.size(); i++) {
if (((ConnectionSpec) this.connectionSpecs.get(i)).isCompatible(sSLSocket)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,289 @@
package okhttp3.internal.connection;
import csdk.gluads.Consts;
import java.io.IOException;
import java.net.ProtocolException;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.Internal;
import okhttp3.internal.http.ExchangeCodec;
import okhttp3.internal.http.RealResponseBody;
import okio.Buffer;
import okio.ForwardingSink;
import okio.ForwardingSource;
import okio.Okio;
import okio.Sink;
import okio.Source;
/* loaded from: classes5.dex */
public final class Exchange {
public final Call call;
public final ExchangeCodec codec;
public boolean duplex;
public final EventListener eventListener;
public final ExchangeFinder finder;
public final Transmitter transmitter;
public boolean isDuplex() {
return this.duplex;
}
public Exchange(Transmitter transmitter, Call call, EventListener eventListener, ExchangeFinder exchangeFinder, ExchangeCodec exchangeCodec) {
this.transmitter = transmitter;
this.call = call;
this.eventListener = eventListener;
this.finder = exchangeFinder;
this.codec = exchangeCodec;
}
public RealConnection connection() {
return this.codec.connection();
}
public void writeRequestHeaders(Request request) {
try {
this.eventListener.requestHeadersStart(this.call);
this.codec.writeRequestHeaders(request);
this.eventListener.requestHeadersEnd(this.call, request);
} catch (IOException e) {
this.eventListener.requestFailed(this.call, e);
trackFailure(e);
throw e;
}
}
public Sink createRequestBody(Request request, boolean z) {
this.duplex = z;
long contentLength = request.body().contentLength();
this.eventListener.requestBodyStart(this.call);
return new RequestBodySink(this.codec.createRequestBody(request, contentLength), contentLength);
}
public void flushRequest() {
try {
this.codec.flushRequest();
} catch (IOException e) {
this.eventListener.requestFailed(this.call, e);
trackFailure(e);
throw e;
}
}
public void finishRequest() {
try {
this.codec.finishRequest();
} catch (IOException e) {
this.eventListener.requestFailed(this.call, e);
trackFailure(e);
throw e;
}
}
public void responseHeadersStart() {
this.eventListener.responseHeadersStart(this.call);
}
public Response.Builder readResponseHeaders(boolean z) {
try {
Response.Builder readResponseHeaders = this.codec.readResponseHeaders(z);
if (readResponseHeaders != null) {
Internal.instance.initExchange(readResponseHeaders, this);
}
return readResponseHeaders;
} catch (IOException e) {
this.eventListener.responseFailed(this.call, e);
trackFailure(e);
throw e;
}
}
public void responseHeadersEnd(Response response) {
this.eventListener.responseHeadersEnd(this.call, response);
}
public ResponseBody openResponseBody(Response response) {
try {
this.eventListener.responseBodyStart(this.call);
String header = response.header("Content-Type");
long reportedContentLength = this.codec.reportedContentLength(response);
return new RealResponseBody(header, reportedContentLength, Okio.buffer(new ResponseBodySource(this.codec.openResponseBodySource(response), reportedContentLength)));
} catch (IOException e) {
this.eventListener.responseFailed(this.call, e);
trackFailure(e);
throw e;
}
}
public void noNewExchangesOnConnection() {
this.codec.connection().noNewExchanges();
}
public void cancel() {
this.codec.cancel();
}
public void detachWithViolence() {
this.codec.cancel();
this.transmitter.exchangeMessageDone(this, true, true, null);
}
public void trackFailure(IOException iOException) {
this.finder.trackFailure();
this.codec.connection().trackFailure(iOException);
}
public IOException bodyComplete(long j, boolean z, boolean z2, IOException iOException) {
if (iOException != null) {
trackFailure(iOException);
}
if (z2) {
if (iOException != null) {
this.eventListener.requestFailed(this.call, iOException);
} else {
this.eventListener.requestBodyEnd(this.call, j);
}
}
if (z) {
if (iOException != null) {
this.eventListener.responseFailed(this.call, iOException);
} else {
this.eventListener.responseBodyEnd(this.call, j);
}
}
return this.transmitter.exchangeMessageDone(this, z2, z, iOException);
}
public void noRequestBody() {
this.transmitter.exchangeMessageDone(this, true, false, null);
}
public final class RequestBodySink extends ForwardingSink {
public long bytesReceived;
public boolean closed;
public boolean completed;
public long contentLength;
public RequestBodySink(Sink sink, long j) {
super(sink);
this.contentLength = j;
}
@Override // okio.ForwardingSink, okio.Sink
public void write(Buffer buffer, long j) {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
long j2 = this.contentLength;
if (j2 != -1 && this.bytesReceived + j > j2) {
throw new ProtocolException("expected " + this.contentLength + " bytes but received " + (this.bytesReceived + j));
}
try {
super.write(buffer, j);
this.bytesReceived += j;
} catch (IOException e) {
throw complete(e);
}
}
@Override // okio.ForwardingSink, okio.Sink, java.io.Flushable
public void flush() {
try {
super.flush();
} catch (IOException e) {
throw complete(e);
}
}
@Override // okio.ForwardingSink, okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.closed) {
return;
}
this.closed = true;
long j = this.contentLength;
if (j != -1 && this.bytesReceived != j) {
throw new ProtocolException("unexpected end of stream");
}
try {
super.close();
complete(null);
} catch (IOException e) {
throw complete(e);
}
}
private IOException complete(IOException iOException) {
if (this.completed) {
return iOException;
}
this.completed = true;
return Exchange.this.bodyComplete(this.bytesReceived, false, true, iOException);
}
}
public final class ResponseBodySource extends ForwardingSource {
public long bytesReceived;
public boolean closed;
public boolean completed;
public final long contentLength;
public ResponseBodySource(Source source, long j) {
super(source);
this.contentLength = j;
if (j == 0) {
complete(null);
}
}
@Override // okio.ForwardingSource, okio.Source
public long read(Buffer buffer, long j) {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
try {
long read = delegate().read(buffer, j);
if (read == -1) {
complete(null);
return -1L;
}
long j2 = this.bytesReceived + read;
long j3 = this.contentLength;
if (j3 != -1 && j2 > j3) {
throw new ProtocolException("expected " + this.contentLength + " bytes but received " + j2);
}
this.bytesReceived = j2;
if (j2 == j3) {
complete(null);
}
return read;
} catch (IOException e) {
throw complete(e);
}
}
@Override // okio.ForwardingSource, okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.closed) {
return;
}
this.closed = true;
try {
super.close();
complete(null);
} catch (IOException e) {
throw complete(e);
}
}
public IOException complete(IOException iOException) {
if (this.completed) {
return iOException;
}
this.completed = true;
return Exchange.this.bodyComplete(this.bytesReceived, true, false, iOException);
}
}
}

View File

@@ -0,0 +1,225 @@
package okhttp3.internal.connection;
import java.io.IOException;
import java.net.Socket;
import java.util.List;
import okhttp3.Address;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Route;
import okhttp3.internal.Util;
import okhttp3.internal.connection.RouteSelector;
import okhttp3.internal.http.ExchangeCodec;
/* loaded from: classes5.dex */
public final class ExchangeFinder {
public final Address address;
public final Call call;
public RealConnection connectingConnection;
public final RealConnectionPool connectionPool;
public final EventListener eventListener;
public boolean hasStreamFailure;
public Route nextRouteToTry;
public RouteSelector.Selection routeSelection;
public final RouteSelector routeSelector;
public final Transmitter transmitter;
public RealConnection connectingConnection() {
return this.connectingConnection;
}
public ExchangeFinder(Transmitter transmitter, RealConnectionPool realConnectionPool, Address address, Call call, EventListener eventListener) {
this.transmitter = transmitter;
this.connectionPool = realConnectionPool;
this.address = address;
this.call = call;
this.eventListener = eventListener;
this.routeSelector = new RouteSelector(address, realConnectionPool.routeDatabase, call, eventListener);
}
public ExchangeCodec find(OkHttpClient okHttpClient, Interceptor.Chain chain, boolean z) {
try {
return findHealthyConnection(chain.connectTimeoutMillis(), chain.readTimeoutMillis(), chain.writeTimeoutMillis(), okHttpClient.pingIntervalMillis(), okHttpClient.retryOnConnectionFailure(), z).newCodec(okHttpClient, chain);
} catch (IOException e) {
trackFailure();
throw new RouteException(e);
} catch (RouteException e2) {
trackFailure();
throw e2;
}
}
public final RealConnection findHealthyConnection(int i, int i2, int i3, int i4, boolean z, boolean z2) {
while (true) {
RealConnection findConnection = findConnection(i, i2, i3, i4, z);
synchronized (this.connectionPool) {
try {
if (findConnection.successCount == 0 && !findConnection.isMultiplexed()) {
return findConnection;
}
if (findConnection.isHealthy(z2)) {
return findConnection;
}
findConnection.noNewExchanges();
} catch (Throwable th) {
throw th;
}
}
}
}
public final RealConnection findConnection(int i, int i2, int i3, int i4, boolean z) {
RealConnection realConnection;
Socket socket;
Socket releaseConnectionNoEvents;
RealConnection realConnection2;
boolean z2;
Route route;
boolean z3;
List list;
RouteSelector.Selection selection;
synchronized (this.connectionPool) {
try {
if (this.transmitter.isCanceled()) {
throw new IOException("Canceled");
}
this.hasStreamFailure = false;
Transmitter transmitter = this.transmitter;
realConnection = transmitter.connection;
socket = null;
releaseConnectionNoEvents = (realConnection == null || !realConnection.noNewExchanges) ? null : transmitter.releaseConnectionNoEvents();
Transmitter transmitter2 = this.transmitter;
realConnection2 = transmitter2.connection;
if (realConnection2 != null) {
realConnection = null;
} else {
realConnection2 = null;
}
if (realConnection2 == null) {
if (this.connectionPool.transmitterAcquirePooledConnection(this.address, transmitter2, null, false)) {
realConnection2 = this.transmitter.connection;
route = null;
z2 = true;
} else {
route = this.nextRouteToTry;
if (route != null) {
this.nextRouteToTry = null;
} else if (retryCurrentRoute()) {
route = this.transmitter.connection.route();
}
z2 = false;
}
}
z2 = false;
route = null;
} finally {
}
}
Util.closeQuietly(releaseConnectionNoEvents);
if (realConnection != null) {
this.eventListener.connectionReleased(this.call, realConnection);
}
if (z2) {
this.eventListener.connectionAcquired(this.call, realConnection2);
}
if (realConnection2 != null) {
return realConnection2;
}
if (route != null || ((selection = this.routeSelection) != null && selection.hasNext())) {
z3 = false;
} else {
this.routeSelection = this.routeSelector.next();
z3 = true;
}
synchronized (this.connectionPool) {
try {
if (this.transmitter.isCanceled()) {
throw new IOException("Canceled");
}
if (z3) {
list = this.routeSelection.getAll();
if (this.connectionPool.transmitterAcquirePooledConnection(this.address, this.transmitter, list, false)) {
realConnection2 = this.transmitter.connection;
z2 = true;
}
} else {
list = null;
}
if (!z2) {
if (route == null) {
route = this.routeSelection.next();
}
realConnection2 = new RealConnection(this.connectionPool, route);
this.connectingConnection = realConnection2;
}
} finally {
}
}
if (z2) {
this.eventListener.connectionAcquired(this.call, realConnection2);
return realConnection2;
}
realConnection2.connect(i, i2, i3, i4, z, this.call, this.eventListener);
this.connectionPool.routeDatabase.connected(realConnection2.route());
synchronized (this.connectionPool) {
try {
this.connectingConnection = null;
if (this.connectionPool.transmitterAcquirePooledConnection(this.address, this.transmitter, list, true)) {
realConnection2.noNewExchanges = true;
socket = realConnection2.socket();
realConnection2 = this.transmitter.connection;
this.nextRouteToTry = route;
} else {
this.connectionPool.put(realConnection2);
this.transmitter.acquireConnectionNoEvents(realConnection2);
}
} finally {
}
}
Util.closeQuietly(socket);
this.eventListener.connectionAcquired(this.call, realConnection2);
return realConnection2;
}
public void trackFailure() {
synchronized (this.connectionPool) {
this.hasStreamFailure = true;
}
}
public boolean hasStreamFailure() {
boolean z;
synchronized (this.connectionPool) {
z = this.hasStreamFailure;
}
return z;
}
public boolean hasRouteToTry() {
synchronized (this.connectionPool) {
try {
boolean z = true;
if (this.nextRouteToTry != null) {
return true;
}
if (retryCurrentRoute()) {
this.nextRouteToTry = this.transmitter.connection.route();
return true;
}
RouteSelector.Selection selection = this.routeSelection;
if ((selection == null || !selection.hasNext()) && !this.routeSelector.hasNext()) {
z = false;
}
return z;
} finally {
}
}
}
public final boolean retryCurrentRoute() {
RealConnection realConnection = this.transmitter.connection;
return realConnection != null && realConnection.routeFailureCount == 0 && Util.sameConnection(realConnection.route().address().url(), this.address.url());
}
}

View File

@@ -0,0 +1,433 @@
package okhttp3.internal.connection;
import com.facebook.internal.security.CertificateUtil;
import java.io.IOException;
import java.net.ConnectException;
import java.net.Proxy;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import okhttp3.Address;
import okhttp3.Call;
import okhttp3.CertificatePinner;
import okhttp3.Connection;
import okhttp3.ConnectionSpec;
import okhttp3.EventListener;
import okhttp3.Handshake;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.Version;
import okhttp3.internal.http.ExchangeCodec;
import okhttp3.internal.http1.Http1ExchangeCodec;
import okhttp3.internal.http2.ConnectionShutdownException;
import okhttp3.internal.http2.ErrorCode;
import okhttp3.internal.http2.Http2Connection;
import okhttp3.internal.http2.Http2ExchangeCodec;
import okhttp3.internal.http2.Http2Stream;
import okhttp3.internal.http2.StreamResetException;
import okhttp3.internal.platform.Platform;
import okhttp3.internal.tls.OkHostnameVerifier;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.Okio;
import okio.Timeout;
import org.apache.http.auth.AUTH;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class RealConnection extends Http2Connection.Listener implements Connection {
public final RealConnectionPool connectionPool;
public Handshake handshake;
public Http2Connection http2Connection;
public boolean noNewExchanges;
public Protocol protocol;
public Socket rawSocket;
public int refusedStreamCount;
public final Route route;
public int routeFailureCount;
public BufferedSink sink;
public Socket socket;
public BufferedSource source;
public int successCount;
public int allocationLimit = 1;
public final List transmitters = new ArrayList();
public long idleAtNanos = Long.MAX_VALUE;
public Handshake handshake() {
return this.handshake;
}
public boolean isMultiplexed() {
return this.http2Connection != null;
}
public Route route() {
return this.route;
}
public Socket socket() {
return this.socket;
}
public RealConnection(RealConnectionPool realConnectionPool, Route route) {
this.connectionPool = realConnectionPool;
this.route = route;
}
public void noNewExchanges() {
synchronized (this.connectionPool) {
this.noNewExchanges = true;
}
}
/* JADX WARN: Removed duplicated region for block: B:32:0x00ed */
/* JADX WARN: Removed duplicated region for block: B:43:0x00fd A[ORIG_RETURN, RETURN] */
/* JADX WARN: Removed duplicated region for block: B:47:0x0131 */
/* JADX WARN: Removed duplicated region for block: B:49:0x013c */
/* JADX WARN: Removed duplicated region for block: B:54:0x0144 A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:56:0x0137 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void connect(int r17, int r18, int r19, int r20, boolean r21, okhttp3.Call r22, okhttp3.EventListener r23) {
/*
Method dump skipped, instructions count: 346
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.connection.RealConnection.connect(int, int, int, int, boolean, okhttp3.Call, okhttp3.EventListener):void");
}
public final void connectTunnel(int i, int i2, int i3, Call call, EventListener eventListener) {
Request createTunnelRequest = createTunnelRequest();
HttpUrl url = createTunnelRequest.url();
for (int i4 = 0; i4 < 21; i4++) {
connectSocket(i, i2, call, eventListener);
createTunnelRequest = createTunnel(i2, i3, createTunnelRequest, url);
if (createTunnelRequest == null) {
return;
}
Util.closeQuietly(this.rawSocket);
this.rawSocket = null;
this.sink = null;
this.source = null;
eventListener.connectEnd(call, this.route.socketAddress(), this.route.proxy(), null);
}
}
public final void connectSocket(int i, int i2, Call call, EventListener eventListener) {
Socket createSocket;
Proxy proxy = this.route.proxy();
Address address = this.route.address();
if (proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.HTTP) {
createSocket = address.socketFactory().createSocket();
} else {
createSocket = new Socket(proxy);
}
this.rawSocket = createSocket;
eventListener.connectStart(call, this.route.socketAddress(), proxy);
this.rawSocket.setSoTimeout(i2);
try {
Platform.get().connectSocket(this.rawSocket, this.route.socketAddress(), i);
try {
this.source = Okio.buffer(Okio.source(this.rawSocket));
this.sink = Okio.buffer(Okio.sink(this.rawSocket));
} catch (NullPointerException e) {
if ("throw with null exception".equals(e.getMessage())) {
throw new IOException(e);
}
}
} catch (ConnectException e2) {
ConnectException connectException = new ConnectException("Failed to connect to " + this.route.socketAddress());
connectException.initCause(e2);
throw connectException;
}
}
public final void establishProtocol(ConnectionSpecSelector connectionSpecSelector, int i, Call call, EventListener eventListener) {
if (this.route.address().sslSocketFactory() == null) {
List protocols = this.route.address().protocols();
Protocol protocol = Protocol.H2_PRIOR_KNOWLEDGE;
if (protocols.contains(protocol)) {
this.socket = this.rawSocket;
this.protocol = protocol;
startHttp2(i);
return;
} else {
this.socket = this.rawSocket;
this.protocol = Protocol.HTTP_1_1;
return;
}
}
eventListener.secureConnectStart(call);
connectTls(connectionSpecSelector);
eventListener.secureConnectEnd(call, this.handshake);
if (this.protocol == Protocol.HTTP_2) {
startHttp2(i);
}
}
public final void startHttp2(int i) {
this.socket.setSoTimeout(0);
Http2Connection build = new Http2Connection.Builder(true).socket(this.socket, this.route.address().url().host(), this.source, this.sink).listener(this).pingIntervalMillis(i).build();
this.http2Connection = build;
build.start();
}
public final void connectTls(ConnectionSpecSelector connectionSpecSelector) {
SSLSocket sSLSocket;
Protocol protocol;
Address address = this.route.address();
SSLSocket sSLSocket2 = null;
try {
try {
sSLSocket = (SSLSocket) address.sslSocketFactory().createSocket(this.rawSocket, address.url().host(), address.url().port(), true);
} catch (AssertionError e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
try {
ConnectionSpec configureSecureSocket = connectionSpecSelector.configureSecureSocket(sSLSocket);
if (configureSecureSocket.supportsTlsExtensions()) {
Platform.get().configureTlsExtensions(sSLSocket, address.url().host(), address.protocols());
}
sSLSocket.startHandshake();
SSLSession session = sSLSocket.getSession();
Handshake handshake = Handshake.get(session);
if (!address.hostnameVerifier().verify(address.url().host(), session)) {
List peerCertificates = handshake.peerCertificates();
if (!peerCertificates.isEmpty()) {
X509Certificate x509Certificate = (X509Certificate) peerCertificates.get(0);
throw new SSLPeerUnverifiedException("Hostname " + address.url().host() + " not verified:\n certificate: " + CertificatePinner.pin(x509Certificate) + "\n DN: " + x509Certificate.getSubjectDN().getName() + "\n subjectAltNames: " + OkHostnameVerifier.allSubjectAltNames(x509Certificate));
}
throw new SSLPeerUnverifiedException("Hostname " + address.url().host() + " not verified (no certificates)");
}
address.certificatePinner().check(address.url().host(), handshake.peerCertificates());
String selectedProtocol = configureSecureSocket.supportsTlsExtensions() ? Platform.get().getSelectedProtocol(sSLSocket) : null;
this.socket = sSLSocket;
this.source = Okio.buffer(Okio.source(sSLSocket));
this.sink = Okio.buffer(Okio.sink(this.socket));
this.handshake = handshake;
if (selectedProtocol != null) {
protocol = Protocol.get(selectedProtocol);
} else {
protocol = Protocol.HTTP_1_1;
}
this.protocol = protocol;
Platform.get().afterHandshake(sSLSocket);
} catch (AssertionError e2) {
e = e2;
if (!Util.isAndroidGetsocknameError(e)) {
throw e;
}
throw new IOException(e);
} catch (Throwable th2) {
th = th2;
sSLSocket2 = sSLSocket;
if (sSLSocket2 != null) {
Platform.get().afterHandshake(sSLSocket2);
}
Util.closeQuietly((Socket) sSLSocket2);
throw th;
}
}
public final Request createTunnel(int i, int i2, Request request, HttpUrl httpUrl) {
String str = "CONNECT " + Util.hostHeader(httpUrl, true) + " HTTP/1.1";
while (true) {
Http1ExchangeCodec http1ExchangeCodec = new Http1ExchangeCodec(null, null, this.source, this.sink);
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
this.source.timeout().timeout(i, timeUnit);
this.sink.timeout().timeout(i2, timeUnit);
http1ExchangeCodec.writeRequest(request.headers(), str);
http1ExchangeCodec.finishRequest();
Response build = http1ExchangeCodec.readResponseHeaders(false).request(request).build();
http1ExchangeCodec.skipConnectBody(build);
int code = build.code();
if (code == 200) {
if (this.source.getBuffer().exhausted() && this.sink.buffer().exhausted()) {
return null;
}
throw new IOException("TLS tunnel buffered too many bytes!");
}
if (code == 407) {
Request authenticate = this.route.address().proxyAuthenticator().authenticate(this.route, build);
if (authenticate == null) {
throw new IOException("Failed to authenticate with proxy");
}
if ("close".equalsIgnoreCase(build.header(HTTP.CONN_DIRECTIVE))) {
return authenticate;
}
request = authenticate;
} else {
throw new IOException("Unexpected response code for CONNECT: " + build.code());
}
}
}
public final Request createTunnelRequest() {
Request build = new Request.Builder().url(this.route.address().url()).method("CONNECT", null).header(HTTP.TARGET_HOST, Util.hostHeader(this.route.address().url(), true)).header("Proxy-Connection", HTTP.CONN_KEEP_ALIVE).header("User-Agent", Version.userAgent()).build();
Request authenticate = this.route.address().proxyAuthenticator().authenticate(this.route, new Response.Builder().request(build).protocol(Protocol.HTTP_1_1).code(407).message("Preemptive Authenticate").body(Util.EMPTY_RESPONSE).sentRequestAtMillis(-1L).receivedResponseAtMillis(-1L).header(AUTH.PROXY_AUTH, "OkHttp-Preemptive").build());
return authenticate != null ? authenticate : build;
}
public boolean isEligible(Address address, List list) {
if (this.transmitters.size() >= this.allocationLimit || this.noNewExchanges || !Internal.instance.equalsNonHost(this.route.address(), address)) {
return false;
}
if (address.url().host().equals(route().address().url().host())) {
return true;
}
if (this.http2Connection == null || list == null || !routeMatchesAny(list) || address.hostnameVerifier() != OkHostnameVerifier.INSTANCE || !supportsUrl(address.url())) {
return false;
}
try {
address.certificatePinner().check(address.url().host(), handshake().peerCertificates());
return true;
} catch (SSLPeerUnverifiedException unused) {
return false;
}
}
public final boolean routeMatchesAny(List list) {
int size = list.size();
for (int i = 0; i < size; i++) {
Route route = (Route) list.get(i);
Proxy.Type type = route.proxy().type();
Proxy.Type type2 = Proxy.Type.DIRECT;
if (type == type2 && this.route.proxy().type() == type2 && this.route.socketAddress().equals(route.socketAddress())) {
return true;
}
}
return false;
}
public boolean supportsUrl(HttpUrl httpUrl) {
if (httpUrl.port() != this.route.address().url().port()) {
return false;
}
if (httpUrl.host().equals(this.route.address().url().host())) {
return true;
}
return this.handshake != null && OkHostnameVerifier.INSTANCE.verify(httpUrl.host(), (X509Certificate) this.handshake.peerCertificates().get(0));
}
public ExchangeCodec newCodec(OkHttpClient okHttpClient, Interceptor.Chain chain) {
if (this.http2Connection != null) {
return new Http2ExchangeCodec(okHttpClient, this, chain, this.http2Connection);
}
this.socket.setSoTimeout(chain.readTimeoutMillis());
Timeout timeout = this.source.timeout();
long readTimeoutMillis = chain.readTimeoutMillis();
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
timeout.timeout(readTimeoutMillis, timeUnit);
this.sink.timeout().timeout(chain.writeTimeoutMillis(), timeUnit);
return new Http1ExchangeCodec(okHttpClient, this, this.source, this.sink);
}
public void cancel() {
Util.closeQuietly(this.rawSocket);
}
public boolean isHealthy(boolean z) {
if (this.socket.isClosed() || this.socket.isInputShutdown() || this.socket.isOutputShutdown()) {
return false;
}
Http2Connection http2Connection = this.http2Connection;
if (http2Connection != null) {
return http2Connection.isHealthy(System.nanoTime());
}
if (z) {
try {
int soTimeout = this.socket.getSoTimeout();
try {
this.socket.setSoTimeout(1);
return !this.source.exhausted();
} finally {
this.socket.setSoTimeout(soTimeout);
}
} catch (SocketTimeoutException unused) {
} catch (IOException unused2) {
return false;
}
}
return true;
}
@Override // okhttp3.internal.http2.Http2Connection.Listener
public void onStream(Http2Stream http2Stream) {
http2Stream.close(ErrorCode.REFUSED_STREAM, null);
}
@Override // okhttp3.internal.http2.Http2Connection.Listener
public void onSettings(Http2Connection http2Connection) {
synchronized (this.connectionPool) {
this.allocationLimit = http2Connection.maxConcurrentStreams();
}
}
public void trackFailure(IOException iOException) {
synchronized (this.connectionPool) {
try {
if (iOException instanceof StreamResetException) {
ErrorCode errorCode = ((StreamResetException) iOException).errorCode;
if (errorCode == ErrorCode.REFUSED_STREAM) {
int i = this.refusedStreamCount + 1;
this.refusedStreamCount = i;
if (i > 1) {
this.noNewExchanges = true;
this.routeFailureCount++;
}
} else if (errorCode != ErrorCode.CANCEL) {
this.noNewExchanges = true;
this.routeFailureCount++;
}
} else if (!isMultiplexed() || (iOException instanceof ConnectionShutdownException)) {
this.noNewExchanges = true;
if (this.successCount == 0) {
if (iOException != null) {
this.connectionPool.connectFailed(this.route, iOException);
}
this.routeFailureCount++;
}
}
} catch (Throwable th) {
throw th;
}
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Connection{");
sb.append(this.route.address().url().host());
sb.append(CertificateUtil.DELIMITER);
sb.append(this.route.address().url().port());
sb.append(", proxy=");
sb.append(this.route.proxy());
sb.append(" hostAddress=");
sb.append(this.route.socketAddress());
sb.append(" cipherSuite=");
Handshake handshake = this.handshake;
sb.append(handshake != null ? handshake.cipherSuite() : "none");
sb.append(" protocol=");
sb.append(this.protocol);
sb.append('}');
return sb.toString();
}
}

View File

@@ -0,0 +1,157 @@
package okhttp3.internal.connection;
import java.io.IOException;
import java.lang.ref.Reference;
import java.net.Proxy;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import okhttp3.Address;
import okhttp3.Route;
import okhttp3.internal.Util;
import okhttp3.internal.connection.Transmitter;
import okhttp3.internal.platform.Platform;
/* loaded from: classes5.dex */
public final class RealConnectionPool {
public static final Executor executor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue(), Util.threadFactory("OkHttp ConnectionPool", true));
public boolean cleanupRunning;
public final long keepAliveDurationNs;
public final int maxIdleConnections;
public final Runnable cleanupRunnable = new Runnable() { // from class: okhttp3.internal.connection.RealConnectionPool$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
RealConnectionPool.this.lambda$new$0();
}
};
public final Deque connections = new ArrayDeque();
public final RouteDatabase routeDatabase = new RouteDatabase();
public final /* synthetic */ void lambda$new$0() {
while (true) {
long cleanup = cleanup(System.nanoTime());
if (cleanup == -1) {
return;
}
if (cleanup > 0) {
long j = cleanup / 1000000;
long j2 = cleanup - (1000000 * j);
synchronized (this) {
try {
wait(j, (int) j2);
} catch (InterruptedException unused) {
}
}
}
}
}
public RealConnectionPool(int i, long j, TimeUnit timeUnit) {
this.maxIdleConnections = i;
this.keepAliveDurationNs = timeUnit.toNanos(j);
if (j > 0) {
return;
}
throw new IllegalArgumentException("keepAliveDuration <= 0: " + j);
}
public boolean transmitterAcquirePooledConnection(Address address, Transmitter transmitter, List list, boolean z) {
for (RealConnection realConnection : this.connections) {
if (!z || realConnection.isMultiplexed()) {
if (realConnection.isEligible(address, list)) {
transmitter.acquireConnectionNoEvents(realConnection);
return true;
}
}
}
return false;
}
public void put(RealConnection realConnection) {
if (!this.cleanupRunning) {
this.cleanupRunning = true;
executor.execute(this.cleanupRunnable);
}
this.connections.add(realConnection);
}
public boolean connectionBecameIdle(RealConnection realConnection) {
if (realConnection.noNewExchanges || this.maxIdleConnections == 0) {
this.connections.remove(realConnection);
return true;
}
notifyAll();
return false;
}
public long cleanup(long j) {
synchronized (this) {
try {
RealConnection realConnection = null;
long j2 = Long.MIN_VALUE;
int i = 0;
int i2 = 0;
for (RealConnection realConnection2 : this.connections) {
if (pruneAndGetAllocationCount(realConnection2, j) > 0) {
i2++;
} else {
i++;
long j3 = j - realConnection2.idleAtNanos;
if (j3 > j2) {
realConnection = realConnection2;
j2 = j3;
}
}
}
long j4 = this.keepAliveDurationNs;
if (j2 < j4 && i <= this.maxIdleConnections) {
if (i > 0) {
return j4 - j2;
}
if (i2 > 0) {
return j4;
}
this.cleanupRunning = false;
return -1L;
}
this.connections.remove(realConnection);
Util.closeQuietly(realConnection.socket());
return 0L;
} catch (Throwable th) {
throw th;
}
}
}
public final int pruneAndGetAllocationCount(RealConnection realConnection, long j) {
List list = realConnection.transmitters;
int i = 0;
while (i < list.size()) {
Reference reference = (Reference) list.get(i);
if (reference.get() != null) {
i++;
} else {
Platform.get().logCloseableLeak("A connection to " + realConnection.route().address().url() + " was leaked. Did you forget to close a response body?", ((Transmitter.TransmitterReference) reference).callStackTrace);
list.remove(i);
realConnection.noNewExchanges = true;
if (list.isEmpty()) {
realConnection.idleAtNanos = j - this.keepAliveDurationNs;
return 0;
}
}
}
return list.size();
}
public void connectFailed(Route route, IOException iOException) {
if (route.proxy().type() != Proxy.Type.DIRECT) {
Address address = route.address();
address.proxySelector().connectFailed(address.url().uri(), route.proxy().address(), iOException);
}
this.routeDatabase.failed(route);
}
}

View File

@@ -0,0 +1,22 @@
package okhttp3.internal.connection;
import java.util.LinkedHashSet;
import java.util.Set;
import okhttp3.Route;
/* loaded from: classes5.dex */
public final class RouteDatabase {
public final Set failedRoutes = new LinkedHashSet();
public synchronized void failed(Route route) {
this.failedRoutes.add(route);
}
public synchronized void connected(Route route) {
this.failedRoutes.remove(route);
}
public synchronized boolean shouldPostpone(Route route) {
return this.failedRoutes.contains(route);
}
}

View File

@@ -0,0 +1,29 @@
package okhttp3.internal.connection;
import java.io.IOException;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class RouteException extends RuntimeException {
public IOException firstException;
public IOException lastException;
public IOException getFirstConnectException() {
return this.firstException;
}
public IOException getLastConnectException() {
return this.lastException;
}
public RouteException(IOException iOException) {
super(iOException);
this.firstException = iOException;
this.lastException = iOException;
}
public void addConnectException(IOException iOException) {
Util.addSuppressedIfPossible(this.firstException, iOException);
this.lastException = iOException;
}
}

View File

@@ -0,0 +1,166 @@
package okhttp3.internal.connection;
import com.facebook.internal.security.CertificateUtil;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import okhttp3.Address;
import okhttp3.Call;
import okhttp3.EventListener;
import okhttp3.HttpUrl;
import okhttp3.Route;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class RouteSelector {
public final Address address;
public final Call call;
public final EventListener eventListener;
public int nextProxyIndex;
public final RouteDatabase routeDatabase;
public List proxies = Collections.emptyList();
public List inetSocketAddresses = Collections.emptyList();
public final List postponedRoutes = new ArrayList();
public RouteSelector(Address address, RouteDatabase routeDatabase, Call call, EventListener eventListener) {
this.address = address;
this.routeDatabase = routeDatabase;
this.call = call;
this.eventListener = eventListener;
resetNextProxy(address.url(), address.proxy());
}
public boolean hasNext() {
return hasNextProxy() || !this.postponedRoutes.isEmpty();
}
public Selection next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
ArrayList arrayList = new ArrayList();
while (hasNextProxy()) {
Proxy nextProxy = nextProxy();
int size = this.inetSocketAddresses.size();
for (int i = 0; i < size; i++) {
Route route = new Route(this.address, nextProxy, (InetSocketAddress) this.inetSocketAddresses.get(i));
if (this.routeDatabase.shouldPostpone(route)) {
this.postponedRoutes.add(route);
} else {
arrayList.add(route);
}
}
if (!arrayList.isEmpty()) {
break;
}
}
if (arrayList.isEmpty()) {
arrayList.addAll(this.postponedRoutes);
this.postponedRoutes.clear();
}
return new Selection(arrayList);
}
public final void resetNextProxy(HttpUrl httpUrl, Proxy proxy) {
if (proxy != null) {
this.proxies = Collections.singletonList(proxy);
} else {
List<Proxy> select = this.address.proxySelector().select(httpUrl.uri());
this.proxies = (select == null || select.isEmpty()) ? Util.immutableList(Proxy.NO_PROXY) : Util.immutableList(select);
}
this.nextProxyIndex = 0;
}
public final boolean hasNextProxy() {
return this.nextProxyIndex < this.proxies.size();
}
public final Proxy nextProxy() {
if (!hasNextProxy()) {
throw new SocketException("No route to " + this.address.url().host() + "; exhausted proxy configurations: " + this.proxies);
}
List list = this.proxies;
int i = this.nextProxyIndex;
this.nextProxyIndex = i + 1;
Proxy proxy = (Proxy) list.get(i);
resetNextInetSocketAddress(proxy);
return proxy;
}
public final void resetNextInetSocketAddress(Proxy proxy) {
String host;
int port;
this.inetSocketAddresses = new ArrayList();
if (proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.SOCKS) {
host = this.address.url().host();
port = this.address.url().port();
} else {
SocketAddress address = proxy.address();
if (!(address instanceof InetSocketAddress)) {
throw new IllegalArgumentException("Proxy.address() is not an InetSocketAddress: " + address.getClass());
}
InetSocketAddress inetSocketAddress = (InetSocketAddress) address;
host = getHostString(inetSocketAddress);
port = inetSocketAddress.getPort();
}
if (port < 1 || port > 65535) {
throw new SocketException("No route to " + host + CertificateUtil.DELIMITER + port + "; port is out of range");
}
if (proxy.type() == Proxy.Type.SOCKS) {
this.inetSocketAddresses.add(InetSocketAddress.createUnresolved(host, port));
return;
}
this.eventListener.dnsStart(this.call, host);
List lookup = this.address.dns().lookup(host);
if (lookup.isEmpty()) {
throw new UnknownHostException(this.address.dns() + " returned no addresses for " + host);
}
this.eventListener.dnsEnd(this.call, host, lookup);
int size = lookup.size();
for (int i = 0; i < size; i++) {
this.inetSocketAddresses.add(new InetSocketAddress((InetAddress) lookup.get(i), port));
}
}
public static String getHostString(InetSocketAddress inetSocketAddress) {
InetAddress address = inetSocketAddress.getAddress();
if (address == null) {
return inetSocketAddress.getHostName();
}
return address.getHostAddress();
}
public static final class Selection {
public int nextRouteIndex = 0;
public final List routes;
public Selection(List list) {
this.routes = list;
}
public boolean hasNext() {
return this.nextRouteIndex < this.routes.size();
}
public Route next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
List list = this.routes;
int i = this.nextRouteIndex;
this.nextRouteIndex = i + 1;
return (Route) list.get(i);
}
public List getAll() {
return new ArrayList(this.routes);
}
}
}

View File

@@ -0,0 +1,312 @@
package okhttp3.internal.connection;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.Socket;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Address;
import okhttp3.Call;
import okhttp3.CertificatePinner;
import okhttp3.EventListener;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.platform.Platform;
import okio.AsyncTimeout;
/* loaded from: classes5.dex */
public final class Transmitter {
public final Call call;
public Object callStackTrace;
public boolean canceled;
public final OkHttpClient client;
public RealConnection connection;
public final RealConnectionPool connectionPool;
public final EventListener eventListener;
public Exchange exchange;
public ExchangeFinder exchangeFinder;
public boolean exchangeRequestDone;
public boolean exchangeResponseDone;
public boolean noMoreExchanges;
public Request request;
public final AsyncTimeout timeout;
public boolean timeoutEarlyExit;
public Transmitter(OkHttpClient okHttpClient, Call call) {
AsyncTimeout asyncTimeout = new AsyncTimeout() { // from class: okhttp3.internal.connection.Transmitter.1
@Override // okio.AsyncTimeout
public void timedOut() {
Transmitter.this.cancel();
}
};
this.timeout = asyncTimeout;
this.client = okHttpClient;
this.connectionPool = Internal.instance.realConnectionPool(okHttpClient.connectionPool());
this.call = call;
this.eventListener = okHttpClient.eventListenerFactory().create(call);
asyncTimeout.timeout(okHttpClient.callTimeoutMillis(), TimeUnit.MILLISECONDS);
}
public void timeoutEnter() {
this.timeout.enter();
}
public void timeoutEarlyExit() {
if (this.timeoutEarlyExit) {
throw new IllegalStateException();
}
this.timeoutEarlyExit = true;
this.timeout.exit();
}
public final IOException timeoutExit(IOException iOException) {
if (this.timeoutEarlyExit || !this.timeout.exit()) {
return iOException;
}
InterruptedIOException interruptedIOException = new InterruptedIOException("timeout");
if (iOException != null) {
interruptedIOException.initCause(iOException);
}
return interruptedIOException;
}
public void callStart() {
this.callStackTrace = Platform.get().getStackTraceForCloseable("response.body().close()");
this.eventListener.callStart(this.call);
}
public void prepareToConnect(Request request) {
Request request2 = this.request;
if (request2 != null) {
if (Util.sameConnection(request2.url(), request.url()) && this.exchangeFinder.hasRouteToTry()) {
return;
}
if (this.exchange != null) {
throw new IllegalStateException();
}
if (this.exchangeFinder != null) {
maybeReleaseConnection(null, true);
this.exchangeFinder = null;
}
}
this.request = request;
this.exchangeFinder = new ExchangeFinder(this, this.connectionPool, createAddress(request.url()), this.call, this.eventListener);
}
public final Address createAddress(HttpUrl httpUrl) {
SSLSocketFactory sSLSocketFactory;
HostnameVerifier hostnameVerifier;
CertificatePinner certificatePinner;
if (httpUrl.isHttps()) {
sSLSocketFactory = this.client.sslSocketFactory();
hostnameVerifier = this.client.hostnameVerifier();
certificatePinner = this.client.certificatePinner();
} else {
sSLSocketFactory = null;
hostnameVerifier = null;
certificatePinner = null;
}
return new Address(httpUrl.host(), httpUrl.port(), this.client.dns(), this.client.socketFactory(), sSLSocketFactory, hostnameVerifier, certificatePinner, this.client.proxyAuthenticator(), this.client.proxy(), this.client.protocols(), this.client.connectionSpecs(), this.client.proxySelector());
}
public Exchange newExchange(Interceptor.Chain chain, boolean z) {
synchronized (this.connectionPool) {
if (this.noMoreExchanges) {
throw new IllegalStateException("released");
}
if (this.exchange != null) {
throw new IllegalStateException("cannot make a new request because the previous response is still open: please call response.close()");
}
}
Exchange exchange = new Exchange(this, this.call, this.eventListener, this.exchangeFinder, this.exchangeFinder.find(this.client, chain, z));
synchronized (this.connectionPool) {
this.exchange = exchange;
this.exchangeRequestDone = false;
this.exchangeResponseDone = false;
}
return exchange;
}
public void acquireConnectionNoEvents(RealConnection realConnection) {
if (this.connection != null) {
throw new IllegalStateException();
}
this.connection = realConnection;
realConnection.transmitters.add(new TransmitterReference(this, this.callStackTrace));
}
public Socket releaseConnectionNoEvents() {
int size = this.connection.transmitters.size();
int i = 0;
while (true) {
if (i >= size) {
i = -1;
break;
}
if (((Reference) this.connection.transmitters.get(i)).get() == this) {
break;
}
i++;
}
if (i == -1) {
throw new IllegalStateException();
}
RealConnection realConnection = this.connection;
realConnection.transmitters.remove(i);
this.connection = null;
if (realConnection.transmitters.isEmpty()) {
realConnection.idleAtNanos = System.nanoTime();
if (this.connectionPool.connectionBecameIdle(realConnection)) {
return realConnection.socket();
}
}
return null;
}
public void exchangeDoneDueToException() {
synchronized (this.connectionPool) {
try {
if (this.noMoreExchanges) {
throw new IllegalStateException();
}
this.exchange = null;
} catch (Throwable th) {
throw th;
}
}
}
public IOException exchangeMessageDone(Exchange exchange, boolean z, boolean z2, IOException iOException) {
boolean z3;
synchronized (this.connectionPool) {
try {
Exchange exchange2 = this.exchange;
if (exchange != exchange2) {
return iOException;
}
boolean z4 = true;
if (z) {
z3 = !this.exchangeRequestDone;
this.exchangeRequestDone = true;
} else {
z3 = false;
}
if (z2) {
if (!this.exchangeResponseDone) {
z3 = true;
}
this.exchangeResponseDone = true;
}
if (this.exchangeRequestDone && this.exchangeResponseDone && z3) {
exchange2.connection().successCount++;
this.exchange = null;
} else {
z4 = false;
}
return z4 ? maybeReleaseConnection(iOException, false) : iOException;
} catch (Throwable th) {
throw th;
}
}
}
public IOException noMoreExchanges(IOException iOException) {
synchronized (this.connectionPool) {
this.noMoreExchanges = true;
}
return maybeReleaseConnection(iOException, false);
}
public final IOException maybeReleaseConnection(IOException iOException, boolean z) {
RealConnection realConnection;
Socket releaseConnectionNoEvents;
boolean z2;
synchronized (this.connectionPool) {
if (z) {
try {
if (this.exchange != null) {
throw new IllegalStateException("cannot release connection while it is in use");
}
} catch (Throwable th) {
throw th;
}
}
realConnection = this.connection;
releaseConnectionNoEvents = (realConnection != null && this.exchange == null && (z || this.noMoreExchanges)) ? releaseConnectionNoEvents() : null;
if (this.connection != null) {
realConnection = null;
}
z2 = this.noMoreExchanges && this.exchange == null;
}
Util.closeQuietly(releaseConnectionNoEvents);
if (realConnection != null) {
this.eventListener.connectionReleased(this.call, realConnection);
}
if (z2) {
boolean z3 = iOException != null;
iOException = timeoutExit(iOException);
if (z3) {
this.eventListener.callFailed(this.call, iOException);
} else {
this.eventListener.callEnd(this.call);
}
}
return iOException;
}
public boolean canRetry() {
return this.exchangeFinder.hasStreamFailure() && this.exchangeFinder.hasRouteToTry();
}
public boolean hasExchange() {
boolean z;
synchronized (this.connectionPool) {
z = this.exchange != null;
}
return z;
}
public void cancel() {
Exchange exchange;
RealConnection connectingConnection;
synchronized (this.connectionPool) {
try {
this.canceled = true;
exchange = this.exchange;
ExchangeFinder exchangeFinder = this.exchangeFinder;
connectingConnection = (exchangeFinder == null || exchangeFinder.connectingConnection() == null) ? this.connection : this.exchangeFinder.connectingConnection();
} catch (Throwable th) {
throw th;
}
}
if (exchange != null) {
exchange.cancel();
} else if (connectingConnection != null) {
connectingConnection.cancel();
}
}
public boolean isCanceled() {
boolean z;
synchronized (this.connectionPool) {
z = this.canceled;
}
return z;
}
public static final class TransmitterReference extends WeakReference {
public final Object callStackTrace;
public TransmitterReference(Transmitter transmitter, Object obj) {
super(transmitter);
this.callStackTrace = obj;
}
}
}

View File

@@ -0,0 +1,90 @@
package okhttp3.internal.http;
import com.ironsource.nb;
import com.mbridge.msdk.foundation.download.Command;
import java.util.List;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import okhttp3.internal.Version;
import okio.GzipSource;
import okio.Okio;
import org.apache.http.cookie.SM;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class BridgeInterceptor implements Interceptor {
public final CookieJar cookieJar;
public BridgeInterceptor(CookieJar cookieJar) {
this.cookieJar = cookieJar;
}
@Override // okhttp3.Interceptor
public Response intercept(Interceptor.Chain chain) {
Request request = chain.request();
Request.Builder newBuilder = request.newBuilder();
RequestBody body = request.body();
if (body != null) {
MediaType contentType = body.contentType();
if (contentType != null) {
newBuilder.header("Content-Type", contentType.toString());
}
long contentLength = body.contentLength();
if (contentLength != -1) {
newBuilder.header(HTTP.CONTENT_LEN, Long.toString(contentLength));
newBuilder.removeHeader(HTTP.TRANSFER_ENCODING);
} else {
newBuilder.header(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
newBuilder.removeHeader(HTTP.CONTENT_LEN);
}
}
boolean z = false;
if (request.header(HTTP.TARGET_HOST) == null) {
newBuilder.header(HTTP.TARGET_HOST, Util.hostHeader(request.url(), false));
}
if (request.header(HTTP.CONN_DIRECTIVE) == null) {
newBuilder.header(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
}
if (request.header("Accept-Encoding") == null && request.header(Command.HTTP_HEADER_RANGE) == null) {
newBuilder.header("Accept-Encoding", "gzip");
z = true;
}
List loadForRequest = this.cookieJar.loadForRequest(request.url());
if (!loadForRequest.isEmpty()) {
newBuilder.header(SM.COOKIE, cookieHeader(loadForRequest));
}
if (request.header("User-Agent") == null) {
newBuilder.header("User-Agent", Version.userAgent());
}
Response proceed = chain.proceed(newBuilder.build());
HttpHeaders.receiveHeaders(this.cookieJar, request.url(), proceed.headers());
Response.Builder request2 = proceed.newBuilder().request(request);
if (z && "gzip".equalsIgnoreCase(proceed.header(HTTP.CONTENT_ENCODING)) && HttpHeaders.hasBody(proceed)) {
GzipSource gzipSource = new GzipSource(proceed.body().source());
request2.headers(proceed.headers().newBuilder().removeAll(HTTP.CONTENT_ENCODING).removeAll(HTTP.CONTENT_LEN).build());
request2.body(new RealResponseBody(proceed.header("Content-Type"), -1L, Okio.buffer(gzipSource)));
}
return request2.build();
}
public final String cookieHeader(List list) {
StringBuilder sb = new StringBuilder();
int size = list.size();
for (int i = 0; i < size; i++) {
if (i > 0) {
sb.append("; ");
}
Cookie cookie = (Cookie) list.get(i);
sb.append(cookie.name());
sb.append(nb.T);
sb.append(cookie.value());
}
return sb.toString();
}
}

View File

@@ -0,0 +1,88 @@
package okhttp3.internal.http;
import java.net.ProtocolException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Util;
import okhttp3.internal.connection.Exchange;
import okio.BufferedSink;
import okio.Okio;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class CallServerInterceptor implements Interceptor {
public final boolean forWebSocket;
public CallServerInterceptor(boolean z) {
this.forWebSocket = z;
}
@Override // okhttp3.Interceptor
public Response intercept(Interceptor.Chain chain) {
boolean z;
Response build;
RealInterceptorChain realInterceptorChain = (RealInterceptorChain) chain;
Exchange exchange = realInterceptorChain.exchange();
Request request = realInterceptorChain.request();
long currentTimeMillis = System.currentTimeMillis();
exchange.writeRequestHeaders(request);
Response.Builder builder = null;
if (HttpMethod.permitsRequestBody(request.method()) && request.body() != null) {
if (HTTP.EXPECT_CONTINUE.equalsIgnoreCase(request.header(HTTP.EXPECT_DIRECTIVE))) {
exchange.flushRequest();
exchange.responseHeadersStart();
builder = exchange.readResponseHeaders(true);
z = true;
} else {
z = false;
}
if (builder == null) {
if (request.body().isDuplex()) {
exchange.flushRequest();
request.body().writeTo(Okio.buffer(exchange.createRequestBody(request, true)));
} else {
BufferedSink buffer = Okio.buffer(exchange.createRequestBody(request, false));
request.body().writeTo(buffer);
buffer.close();
}
} else {
exchange.noRequestBody();
if (!exchange.connection().isMultiplexed()) {
exchange.noNewExchangesOnConnection();
}
}
} else {
exchange.noRequestBody();
z = false;
}
if (request.body() == null || !request.body().isDuplex()) {
exchange.finishRequest();
}
if (!z) {
exchange.responseHeadersStart();
}
if (builder == null) {
builder = exchange.readResponseHeaders(false);
}
Response build2 = builder.request(request).handshake(exchange.connection().handshake()).sentRequestAtMillis(currentTimeMillis).receivedResponseAtMillis(System.currentTimeMillis()).build();
int code = build2.code();
if (code == 100) {
build2 = exchange.readResponseHeaders(false).request(request).handshake(exchange.connection().handshake()).sentRequestAtMillis(currentTimeMillis).receivedResponseAtMillis(System.currentTimeMillis()).build();
code = build2.code();
}
exchange.responseHeadersEnd(build2);
if (this.forWebSocket && code == 101) {
build = build2.newBuilder().body(Util.EMPTY_RESPONSE).build();
} else {
build = build2.newBuilder().body(exchange.openResponseBody(build2)).build();
}
if ("close".equalsIgnoreCase(build.request().header(HTTP.CONN_DIRECTIVE)) || "close".equalsIgnoreCase(build.header(HTTP.CONN_DIRECTIVE))) {
exchange.noNewExchangesOnConnection();
}
if ((code != 204 && code != 205) || build.body().contentLength() <= 0) {
return build;
}
throw new ProtocolException("HTTP " + code + " had non-zero Content-Length: " + build.body().contentLength());
}
}

View File

@@ -0,0 +1,28 @@
package okhttp3.internal.http;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.connection.RealConnection;
import okio.Sink;
import okio.Source;
/* loaded from: classes5.dex */
public interface ExchangeCodec {
void cancel();
RealConnection connection();
Sink createRequestBody(Request request, long j);
void finishRequest();
void flushRequest();
Source openResponseBodySource(Response response);
Response.Builder readResponseHeaders(boolean z);
long reportedContentLength(Response response);
void writeRequestHeaders(Request request);
}

View File

@@ -0,0 +1,68 @@
package okhttp3.internal.http;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import okhttp3.internal.Util;
import org.apache.http.impl.cookie.DateUtils;
/* loaded from: classes5.dex */
public abstract class HttpDate {
public static final DateFormat[] BROWSER_COMPATIBLE_DATE_FORMATS;
public static final String[] BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS;
public static final ThreadLocal STANDARD_DATE_FORMAT = new ThreadLocal() { // from class: okhttp3.internal.http.HttpDate.1
@Override // java.lang.ThreadLocal
public DateFormat initialValue() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
simpleDateFormat.setLenient(false);
simpleDateFormat.setTimeZone(Util.UTC);
return simpleDateFormat;
}
};
static {
String[] strArr = {"EEE, dd MMM yyyy HH:mm:ss zzz", DateUtils.PATTERN_RFC1036, DateUtils.PATTERN_ASCTIME, "EEE, dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MMM-yyyy HH-mm-ss z", "EEE, dd MMM yy HH:mm:ss z", "EEE dd-MMM-yyyy HH:mm:ss z", "EEE dd MMM yyyy HH:mm:ss z", "EEE dd-MMM-yyyy HH-mm-ss z", "EEE dd-MMM-yy HH:mm:ss z", "EEE dd MMM yy HH:mm:ss z", "EEE,dd-MMM-yy HH:mm:ss z", "EEE,dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MM-yyyy HH:mm:ss z", "EEE MMM d yyyy HH:mm:ss z"};
BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS = strArr;
BROWSER_COMPATIBLE_DATE_FORMATS = new DateFormat[strArr.length];
}
public static Date parse(String str) {
if (str.length() == 0) {
return null;
}
ParsePosition parsePosition = new ParsePosition(0);
Date parse = ((DateFormat) STANDARD_DATE_FORMAT.get()).parse(str, parsePosition);
if (parsePosition.getIndex() == str.length()) {
return parse;
}
String[] strArr = BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS;
synchronized (strArr) {
try {
int length = strArr.length;
for (int i = 0; i < length; i++) {
DateFormat[] dateFormatArr = BROWSER_COMPATIBLE_DATE_FORMATS;
DateFormat dateFormat = dateFormatArr[i];
if (dateFormat == null) {
dateFormat = new SimpleDateFormat(BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS[i], Locale.US);
dateFormat.setTimeZone(Util.UTC);
dateFormatArr[i] = dateFormat;
}
parsePosition.setIndex(0);
Date parse2 = dateFormat.parse(str, parsePosition);
if (parsePosition.getIndex() != 0) {
return parse2;
}
}
return null;
} catch (Throwable th) {
throw th;
}
}
}
public static String format(Date date) {
return ((DateFormat) STANDARD_DATE_FORMAT.get()).format(date);
}
}

View File

@@ -0,0 +1,151 @@
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;
}
}
}

View File

@@ -0,0 +1,28 @@
package okhttp3.internal.http;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPut;
/* loaded from: classes5.dex */
public abstract class HttpMethod {
public static boolean invalidatesCache(String str) {
return str.equals("POST") || str.equals("PATCH") || str.equals(HttpPut.METHOD_NAME) || str.equals(HttpDelete.METHOD_NAME) || str.equals("MOVE");
}
public static boolean requiresRequestBody(String str) {
return str.equals("POST") || str.equals(HttpPut.METHOD_NAME) || str.equals("PATCH") || str.equals("PROPPATCH") || str.equals("REPORT");
}
public static boolean permitsRequestBody(String str) {
return (str.equals("GET") || str.equals(HttpHead.METHOD_NAME)) ? false : true;
}
public static boolean redirectsWithBody(String str) {
return str.equals("PROPFIND");
}
public static boolean redirectsToGet(String str) {
return !str.equals("PROPFIND");
}
}

View File

@@ -0,0 +1,99 @@
package okhttp3.internal.http;
import java.util.List;
import okhttp3.Call;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.connection.Exchange;
import okhttp3.internal.connection.Transmitter;
/* loaded from: classes5.dex */
public final class RealInterceptorChain implements Interceptor.Chain {
public final Call call;
public int calls;
public final int connectTimeout;
public final Exchange exchange;
public final int index;
public final List interceptors;
public final int readTimeout;
public final Request request;
public final Transmitter transmitter;
public final int writeTimeout;
@Override // okhttp3.Interceptor.Chain
public int connectTimeoutMillis() {
return this.connectTimeout;
}
@Override // okhttp3.Interceptor.Chain
public int readTimeoutMillis() {
return this.readTimeout;
}
@Override // okhttp3.Interceptor.Chain
public Request request() {
return this.request;
}
public Transmitter transmitter() {
return this.transmitter;
}
@Override // okhttp3.Interceptor.Chain
public int writeTimeoutMillis() {
return this.writeTimeout;
}
public RealInterceptorChain(List list, Transmitter transmitter, Exchange exchange, int i, Request request, Call call, int i2, int i3, int i4) {
this.interceptors = list;
this.transmitter = transmitter;
this.exchange = exchange;
this.index = i;
this.request = request;
this.call = call;
this.connectTimeout = i2;
this.readTimeout = i3;
this.writeTimeout = i4;
}
public Exchange exchange() {
Exchange exchange = this.exchange;
if (exchange != null) {
return exchange;
}
throw new IllegalStateException();
}
@Override // okhttp3.Interceptor.Chain
public Response proceed(Request request) {
return proceed(request, this.transmitter, this.exchange);
}
public Response proceed(Request request, Transmitter transmitter, Exchange exchange) {
if (this.index >= this.interceptors.size()) {
throw new AssertionError();
}
this.calls++;
Exchange exchange2 = this.exchange;
if (exchange2 != null && !exchange2.connection().supportsUrl(request.url())) {
throw new IllegalStateException("network interceptor " + this.interceptors.get(this.index - 1) + " must retain the same host and port");
}
if (this.exchange != null && this.calls > 1) {
throw new IllegalStateException("network interceptor " + this.interceptors.get(this.index - 1) + " must call proceed() exactly once");
}
RealInterceptorChain realInterceptorChain = new RealInterceptorChain(this.interceptors, transmitter, exchange, this.index + 1, request, this.call, this.connectTimeout, this.readTimeout, this.writeTimeout);
Interceptor interceptor = (Interceptor) this.interceptors.get(this.index);
Response intercept = interceptor.intercept(realInterceptorChain);
if (exchange != null && this.index + 1 < this.interceptors.size() && realInterceptorChain.calls != 1) {
throw new IllegalStateException("network interceptor " + interceptor + " must call proceed() exactly once");
}
if (intercept == null) {
throw new NullPointerException("interceptor " + interceptor + " returned null");
}
if (intercept.body() != null) {
return intercept;
}
throw new IllegalStateException("interceptor " + interceptor + " returned a response with no body");
}
}

View File

@@ -0,0 +1,37 @@
package okhttp3.internal.http;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import okio.BufferedSource;
/* loaded from: classes5.dex */
public final class RealResponseBody extends ResponseBody {
public final long contentLength;
public final String contentTypeString;
public final BufferedSource source;
@Override // okhttp3.ResponseBody
public long contentLength() {
return this.contentLength;
}
@Override // okhttp3.ResponseBody
public BufferedSource source() {
return this.source;
}
public RealResponseBody(String str, long j, BufferedSource bufferedSource) {
this.contentTypeString = str;
this.contentLength = j;
this.source = bufferedSource;
}
@Override // okhttp3.ResponseBody
public MediaType contentType() {
String str = this.contentTypeString;
if (str != null) {
return MediaType.parse(str);
}
return null;
}
}

View File

@@ -0,0 +1,34 @@
package okhttp3.internal.http;
import java.net.Proxy;
import okhttp3.HttpUrl;
import okhttp3.Request;
/* loaded from: classes5.dex */
public abstract class RequestLine {
public static String get(Request request, Proxy.Type type) {
StringBuilder sb = new StringBuilder();
sb.append(request.method());
sb.append(' ');
if (includeAuthorityInRequestLine(request, type)) {
sb.append(request.url());
} else {
sb.append(requestPath(request.url()));
}
sb.append(" HTTP/1.1");
return sb.toString();
}
public static boolean includeAuthorityInRequestLine(Request request, Proxy.Type type) {
return !request.isHttps() && type == Proxy.Type.HTTP;
}
public static String requestPath(HttpUrl httpUrl) {
String encodedPath = httpUrl.encodedPath();
String encodedQuery = httpUrl.encodedQuery();
if (encodedQuery == null) {
return encodedPath;
}
return encodedPath + '?' + encodedQuery;
}
}

View File

@@ -0,0 +1,206 @@
package okhttp3.internal.http;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.SocketTimeoutException;
import java.security.cert.CertificateException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.Route;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.connection.Exchange;
import okhttp3.internal.connection.RouteException;
import okhttp3.internal.connection.Transmitter;
import okhttp3.internal.http2.ConnectionShutdownException;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class RetryAndFollowUpInterceptor implements Interceptor {
public final OkHttpClient client;
public RetryAndFollowUpInterceptor(OkHttpClient okHttpClient) {
this.client = okHttpClient;
}
@Override // okhttp3.Interceptor
public Response intercept(Interceptor.Chain chain) {
Exchange exchange;
Request followUpRequest;
Request request = chain.request();
RealInterceptorChain realInterceptorChain = (RealInterceptorChain) chain;
Transmitter transmitter = realInterceptorChain.transmitter();
int i = 0;
Response response = null;
while (true) {
transmitter.prepareToConnect(request);
if (transmitter.isCanceled()) {
throw new IOException("Canceled");
}
try {
try {
Response proceed = realInterceptorChain.proceed(request, transmitter, null);
if (response != null) {
proceed = proceed.newBuilder().priorResponse(response.newBuilder().body(null).build()).build();
}
response = proceed;
exchange = Internal.instance.exchange(response);
followUpRequest = followUpRequest(response, exchange != null ? exchange.connection().route() : null);
} catch (IOException e) {
if (!recover(e, transmitter, !(e instanceof ConnectionShutdownException), request)) {
throw e;
}
} catch (RouteException e2) {
if (!recover(e2.getLastConnectException(), transmitter, false, request)) {
throw e2.getFirstConnectException();
}
}
if (followUpRequest == null) {
if (exchange != null && exchange.isDuplex()) {
transmitter.timeoutEarlyExit();
}
return response;
}
RequestBody body = followUpRequest.body();
if (body != null && body.isOneShot()) {
return response;
}
Util.closeQuietly(response.body());
if (transmitter.hasExchange()) {
exchange.detachWithViolence();
}
i++;
if (i > 20) {
throw new ProtocolException("Too many follow-up requests: " + i);
}
request = followUpRequest;
} finally {
transmitter.exchangeDoneDueToException();
}
}
}
public final boolean recover(IOException iOException, Transmitter transmitter, boolean z, Request request) {
if (this.client.retryOnConnectionFailure()) {
return !(z && requestIsOneShot(iOException, request)) && isRecoverable(iOException, z) && transmitter.canRetry();
}
return false;
}
public final boolean requestIsOneShot(IOException iOException, Request request) {
RequestBody body = request.body();
return (body != null && body.isOneShot()) || (iOException instanceof FileNotFoundException);
}
public final boolean isRecoverable(IOException iOException, boolean z) {
if (iOException instanceof ProtocolException) {
return false;
}
return iOException instanceof InterruptedIOException ? (iOException instanceof SocketTimeoutException) && !z : (((iOException instanceof SSLHandshakeException) && (iOException.getCause() instanceof CertificateException)) || (iOException instanceof SSLPeerUnverifiedException)) ? false : true;
}
public final Request followUpRequest(Response response, Route route) {
String header;
HttpUrl resolve;
Proxy proxy;
if (response == null) {
throw new IllegalStateException();
}
int code = response.code();
String method = response.request().method();
if (code == 307 || code == 308) {
if (!method.equals("GET") && !method.equals(HttpHead.METHOD_NAME)) {
return null;
}
} else {
if (code == 401) {
return this.client.authenticator().authenticate(route, response);
}
if (code == 503) {
if ((response.priorResponse() == null || response.priorResponse().code() != 503) && retryAfter(response, Integer.MAX_VALUE) == 0) {
return response.request();
}
return null;
}
if (code == 407) {
if (route != null) {
proxy = route.proxy();
} else {
proxy = this.client.proxy();
}
if (proxy.type() != Proxy.Type.HTTP) {
throw new ProtocolException("Received HTTP_PROXY_AUTH (407) code while not using proxy");
}
return this.client.proxyAuthenticator().authenticate(route, response);
}
if (code == 408) {
if (!this.client.retryOnConnectionFailure()) {
return null;
}
RequestBody body = response.request().body();
if (body != null && body.isOneShot()) {
return null;
}
if ((response.priorResponse() == null || response.priorResponse().code() != 408) && retryAfter(response, 0) <= 0) {
return response.request();
}
return null;
}
switch (code) {
case 300:
case 301:
case 302:
case HttpStatus.SC_SEE_OTHER /* 303 */:
break;
default:
return null;
}
}
if (!this.client.followRedirects() || (header = response.header("Location")) == null || (resolve = response.request().url().resolve(header)) == null) {
return null;
}
if (!resolve.scheme().equals(response.request().url().scheme()) && !this.client.followSslRedirects()) {
return null;
}
Request.Builder newBuilder = response.request().newBuilder();
if (HttpMethod.permitsRequestBody(method)) {
boolean redirectsWithBody = HttpMethod.redirectsWithBody(method);
if (HttpMethod.redirectsToGet(method)) {
newBuilder.method("GET", null);
} else {
newBuilder.method(method, redirectsWithBody ? response.request().body() : null);
}
if (!redirectsWithBody) {
newBuilder.removeHeader(HTTP.TRANSFER_ENCODING);
newBuilder.removeHeader(HTTP.CONTENT_LEN);
newBuilder.removeHeader("Content-Type");
}
}
if (!Util.sameConnection(response.request().url(), resolve)) {
newBuilder.removeHeader("Authorization");
}
return newBuilder.url(resolve).build();
}
public final int retryAfter(Response response, int i) {
String header = response.header("Retry-After");
if (header == null) {
return i;
}
if (header.matches("\\d+")) {
return Integer.valueOf(header).intValue();
}
return Integer.MAX_VALUE;
}
}

View File

@@ -0,0 +1,72 @@
package okhttp3.internal.http;
import java.net.ProtocolException;
import okhttp3.Protocol;
/* loaded from: classes5.dex */
public final class StatusLine {
public final int code;
public final String message;
public final Protocol protocol;
public StatusLine(Protocol protocol, int i, String str) {
this.protocol = protocol;
this.code = i;
this.message = str;
}
public static StatusLine parse(String str) {
Protocol protocol;
int i;
String str2;
if (str.startsWith("HTTP/1.")) {
i = 9;
if (str.length() < 9 || str.charAt(8) != ' ') {
throw new ProtocolException("Unexpected status line: " + 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("Unexpected status line: " + str);
}
} else if (str.startsWith("ICY ")) {
protocol = Protocol.HTTP_1_0;
i = 4;
} else {
throw new ProtocolException("Unexpected status line: " + str);
}
int i2 = i + 3;
if (str.length() < i2) {
throw new ProtocolException("Unexpected status line: " + str);
}
try {
int parseInt = Integer.parseInt(str.substring(i, i2));
if (str.length() <= i2) {
str2 = "";
} else {
if (str.charAt(i2) != ' ') {
throw new ProtocolException("Unexpected status line: " + str);
}
str2 = str.substring(i + 4);
}
return new StatusLine(protocol, parseInt, str2);
} catch (NumberFormatException unused) {
throw new ProtocolException("Unexpected status line: " + str);
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1");
sb.append(' ');
sb.append(this.code);
if (this.message != null) {
sb.append(' ');
sb.append(this.message);
}
return sb.toString();
}
}

View File

@@ -0,0 +1,518 @@
package okhttp3.internal.http1;
import android.support.v4.media.session.PlaybackStateCompat;
import csdk.gluads.Consts;
import java.io.EOFException;
import java.io.IOException;
import java.net.ProtocolException;
import java.util.concurrent.TimeUnit;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.connection.RealConnection;
import okhttp3.internal.http.ExchangeCodec;
import okhttp3.internal.http.HttpHeaders;
import okhttp3.internal.http.RequestLine;
import okhttp3.internal.http.StatusLine;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.ForwardingTimeout;
import okio.Sink;
import okio.Source;
import okio.Timeout;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class Http1ExchangeCodec implements ExchangeCodec {
public final OkHttpClient client;
public final RealConnection realConnection;
public final BufferedSink sink;
public final BufferedSource source;
public Headers trailers;
public int state = 0;
public long headerLimit = PlaybackStateCompat.ACTION_SET_REPEAT_MODE;
@Override // okhttp3.internal.http.ExchangeCodec
public RealConnection connection() {
return this.realConnection;
}
public Http1ExchangeCodec(OkHttpClient okHttpClient, RealConnection realConnection, BufferedSource bufferedSource, BufferedSink bufferedSink) {
this.client = okHttpClient;
this.realConnection = realConnection;
this.source = bufferedSource;
this.sink = bufferedSink;
}
@Override // okhttp3.internal.http.ExchangeCodec
public Sink createRequestBody(Request request, long j) {
if (request.body() != null && request.body().isDuplex()) {
throw new ProtocolException("Duplex connections are not supported for HTTP/1");
}
if (HTTP.CHUNK_CODING.equalsIgnoreCase(request.header(HTTP.TRANSFER_ENCODING))) {
return newChunkedSink();
}
if (j != -1) {
return newKnownLengthSink();
}
throw new IllegalStateException("Cannot stream a request body without chunked encoding or a known content length!");
}
@Override // okhttp3.internal.http.ExchangeCodec
public void cancel() {
RealConnection realConnection = this.realConnection;
if (realConnection != null) {
realConnection.cancel();
}
}
@Override // okhttp3.internal.http.ExchangeCodec
public void writeRequestHeaders(Request request) {
writeRequest(request.headers(), RequestLine.get(request, this.realConnection.route().proxy().type()));
}
@Override // okhttp3.internal.http.ExchangeCodec
public long reportedContentLength(Response response) {
if (!HttpHeaders.hasBody(response)) {
return 0L;
}
if (HTTP.CHUNK_CODING.equalsIgnoreCase(response.header(HTTP.TRANSFER_ENCODING))) {
return -1L;
}
return HttpHeaders.contentLength(response);
}
@Override // okhttp3.internal.http.ExchangeCodec
public Source openResponseBodySource(Response response) {
if (!HttpHeaders.hasBody(response)) {
return newFixedLengthSource(0L);
}
if (HTTP.CHUNK_CODING.equalsIgnoreCase(response.header(HTTP.TRANSFER_ENCODING))) {
return newChunkedSource(response.request().url());
}
long contentLength = HttpHeaders.contentLength(response);
if (contentLength != -1) {
return newFixedLengthSource(contentLength);
}
return newUnknownLengthSource();
}
@Override // okhttp3.internal.http.ExchangeCodec
public void flushRequest() {
this.sink.flush();
}
@Override // okhttp3.internal.http.ExchangeCodec
public void finishRequest() {
this.sink.flush();
}
public void writeRequest(Headers headers, String str) {
if (this.state != 0) {
throw new IllegalStateException("state: " + this.state);
}
this.sink.writeUtf8(str).writeUtf8("\r\n");
int size = headers.size();
for (int i = 0; i < size; i++) {
this.sink.writeUtf8(headers.name(i)).writeUtf8(": ").writeUtf8(headers.value(i)).writeUtf8("\r\n");
}
this.sink.writeUtf8("\r\n");
this.state = 1;
}
@Override // okhttp3.internal.http.ExchangeCodec
public Response.Builder readResponseHeaders(boolean z) {
int i = this.state;
if (i != 1 && i != 3) {
throw new IllegalStateException("state: " + this.state);
}
try {
StatusLine parse = StatusLine.parse(readHeaderLine());
Response.Builder headers = new Response.Builder().protocol(parse.protocol).code(parse.code).message(parse.message).headers(readHeaders());
if (z && parse.code == 100) {
return null;
}
if (parse.code == 100) {
this.state = 3;
return headers;
}
this.state = 4;
return headers;
} catch (EOFException e) {
RealConnection realConnection = this.realConnection;
throw new IOException("unexpected end of stream on " + (realConnection != null ? realConnection.route().address().url().redact() : "unknown"), e);
}
}
public final String readHeaderLine() {
String readUtf8LineStrict = this.source.readUtf8LineStrict(this.headerLimit);
this.headerLimit -= readUtf8LineStrict.length();
return readUtf8LineStrict;
}
public final Headers readHeaders() {
Headers.Builder builder = new Headers.Builder();
while (true) {
String readHeaderLine = readHeaderLine();
if (readHeaderLine.length() != 0) {
Internal.instance.addLenient(builder, readHeaderLine);
} else {
return builder.build();
}
}
}
public final Sink newChunkedSink() {
if (this.state != 1) {
throw new IllegalStateException("state: " + this.state);
}
this.state = 2;
return new ChunkedSink();
}
public final Sink newKnownLengthSink() {
if (this.state != 1) {
throw new IllegalStateException("state: " + this.state);
}
this.state = 2;
return new KnownLengthSink();
}
public final Source newFixedLengthSource(long j) {
if (this.state != 4) {
throw new IllegalStateException("state: " + this.state);
}
this.state = 5;
return new FixedLengthSource(j);
}
public final Source newChunkedSource(HttpUrl httpUrl) {
if (this.state != 4) {
throw new IllegalStateException("state: " + this.state);
}
this.state = 5;
return new ChunkedSource(httpUrl);
}
public final Source newUnknownLengthSource() {
if (this.state != 4) {
throw new IllegalStateException("state: " + this.state);
}
this.state = 5;
this.realConnection.noNewExchanges();
return new UnknownLengthSource();
}
public final void detachTimeout(ForwardingTimeout forwardingTimeout) {
Timeout delegate = forwardingTimeout.delegate();
forwardingTimeout.setDelegate(Timeout.NONE);
delegate.clearDeadline();
delegate.clearTimeout();
}
public void skipConnectBody(Response response) {
long contentLength = HttpHeaders.contentLength(response);
if (contentLength == -1) {
return;
}
Source newFixedLengthSource = newFixedLengthSource(contentLength);
Util.skipAll(newFixedLengthSource, Integer.MAX_VALUE, TimeUnit.MILLISECONDS);
newFixedLengthSource.close();
}
public final class KnownLengthSink implements Sink {
public boolean closed;
public final ForwardingTimeout timeout;
@Override // okio.Sink
public Timeout timeout() {
return this.timeout;
}
public KnownLengthSink() {
this.timeout = new ForwardingTimeout(Http1ExchangeCodec.this.sink.timeout());
}
@Override // okio.Sink
public void write(Buffer buffer, long j) {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
Util.checkOffsetAndCount(buffer.size(), 0L, j);
Http1ExchangeCodec.this.sink.write(buffer, j);
}
@Override // okio.Sink, java.io.Flushable
public void flush() {
if (this.closed) {
return;
}
Http1ExchangeCodec.this.sink.flush();
}
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.closed) {
return;
}
this.closed = true;
Http1ExchangeCodec.this.detachTimeout(this.timeout);
Http1ExchangeCodec.this.state = 3;
}
}
public final class ChunkedSink implements Sink {
public boolean closed;
public final ForwardingTimeout timeout;
@Override // okio.Sink
public Timeout timeout() {
return this.timeout;
}
public ChunkedSink() {
this.timeout = new ForwardingTimeout(Http1ExchangeCodec.this.sink.timeout());
}
@Override // okio.Sink
public void write(Buffer buffer, long j) {
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (j == 0) {
return;
}
Http1ExchangeCodec.this.sink.writeHexadecimalUnsignedLong(j);
Http1ExchangeCodec.this.sink.writeUtf8("\r\n");
Http1ExchangeCodec.this.sink.write(buffer, j);
Http1ExchangeCodec.this.sink.writeUtf8("\r\n");
}
@Override // okio.Sink, java.io.Flushable
public synchronized void flush() {
if (this.closed) {
return;
}
Http1ExchangeCodec.this.sink.flush();
}
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public synchronized void close() {
if (this.closed) {
return;
}
this.closed = true;
Http1ExchangeCodec.this.sink.writeUtf8("0\r\n\r\n");
Http1ExchangeCodec.this.detachTimeout(this.timeout);
Http1ExchangeCodec.this.state = 3;
}
}
public abstract class AbstractSource implements Source {
public boolean closed;
public final ForwardingTimeout timeout;
@Override // okio.Source
public Timeout timeout() {
return this.timeout;
}
public AbstractSource() {
this.timeout = new ForwardingTimeout(Http1ExchangeCodec.this.source.timeout());
}
@Override // okio.Source
public long read(Buffer buffer, long j) {
try {
return Http1ExchangeCodec.this.source.read(buffer, j);
} catch (IOException e) {
Http1ExchangeCodec.this.realConnection.noNewExchanges();
responseBodyComplete();
throw e;
}
}
public final void responseBodyComplete() {
if (Http1ExchangeCodec.this.state == 6) {
return;
}
if (Http1ExchangeCodec.this.state == 5) {
Http1ExchangeCodec.this.detachTimeout(this.timeout);
Http1ExchangeCodec.this.state = 6;
} else {
throw new IllegalStateException("state: " + Http1ExchangeCodec.this.state);
}
}
}
public class FixedLengthSource extends AbstractSource {
public long bytesRemaining;
public FixedLengthSource(long j) {
super();
this.bytesRemaining = j;
if (j == 0) {
responseBodyComplete();
}
}
@Override // okhttp3.internal.http1.Http1ExchangeCodec.AbstractSource, okio.Source
public long read(Buffer buffer, long j) {
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: " + j);
}
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
long j2 = this.bytesRemaining;
if (j2 == 0) {
return -1L;
}
long read = super.read(buffer, Math.min(j2, j));
if (read == -1) {
Http1ExchangeCodec.this.realConnection.noNewExchanges();
ProtocolException protocolException = new ProtocolException("unexpected end of stream");
responseBodyComplete();
throw protocolException;
}
long j3 = this.bytesRemaining - read;
this.bytesRemaining = j3;
if (j3 == 0) {
responseBodyComplete();
}
return read;
}
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.closed) {
return;
}
if (this.bytesRemaining != 0 && !Util.discard(this, 100, TimeUnit.MILLISECONDS)) {
Http1ExchangeCodec.this.realConnection.noNewExchanges();
responseBodyComplete();
}
this.closed = true;
}
}
public class ChunkedSource extends AbstractSource {
public long bytesRemainingInChunk;
public boolean hasMoreChunks;
public final HttpUrl url;
public ChunkedSource(HttpUrl httpUrl) {
super();
this.bytesRemainingInChunk = -1L;
this.hasMoreChunks = true;
this.url = httpUrl;
}
@Override // okhttp3.internal.http1.Http1ExchangeCodec.AbstractSource, okio.Source
public long read(Buffer buffer, long j) {
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: " + j);
}
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (!this.hasMoreChunks) {
return -1L;
}
long j2 = this.bytesRemainingInChunk;
if (j2 == 0 || j2 == -1) {
readChunkSize();
if (!this.hasMoreChunks) {
return -1L;
}
}
long read = super.read(buffer, Math.min(j, this.bytesRemainingInChunk));
if (read != -1) {
this.bytesRemainingInChunk -= read;
return read;
}
Http1ExchangeCodec.this.realConnection.noNewExchanges();
ProtocolException protocolException = new ProtocolException("unexpected end of stream");
responseBodyComplete();
throw protocolException;
}
public final void readChunkSize() {
if (this.bytesRemainingInChunk != -1) {
Http1ExchangeCodec.this.source.readUtf8LineStrict();
}
try {
this.bytesRemainingInChunk = Http1ExchangeCodec.this.source.readHexadecimalUnsignedLong();
String trim = Http1ExchangeCodec.this.source.readUtf8LineStrict().trim();
if (this.bytesRemainingInChunk < 0 || !(trim.isEmpty() || trim.startsWith(";"))) {
throw new ProtocolException("expected chunk size and optional extensions but was \"" + this.bytesRemainingInChunk + trim + "\"");
}
if (this.bytesRemainingInChunk == 0) {
this.hasMoreChunks = false;
Http1ExchangeCodec http1ExchangeCodec = Http1ExchangeCodec.this;
http1ExchangeCodec.trailers = http1ExchangeCodec.readHeaders();
HttpHeaders.receiveHeaders(Http1ExchangeCodec.this.client.cookieJar(), this.url, Http1ExchangeCodec.this.trailers);
responseBodyComplete();
}
} catch (NumberFormatException e) {
throw new ProtocolException(e.getMessage());
}
}
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.closed) {
return;
}
if (this.hasMoreChunks && !Util.discard(this, 100, TimeUnit.MILLISECONDS)) {
Http1ExchangeCodec.this.realConnection.noNewExchanges();
responseBodyComplete();
}
this.closed = true;
}
}
public class UnknownLengthSource extends AbstractSource {
public boolean inputExhausted;
public UnknownLengthSource() {
super();
}
@Override // okhttp3.internal.http1.Http1ExchangeCodec.AbstractSource, okio.Source
public long read(Buffer buffer, long j) {
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: " + j);
}
if (this.closed) {
throw new IllegalStateException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (this.inputExhausted) {
return -1L;
}
long read = super.read(buffer, j);
if (read != -1) {
return read;
}
this.inputExhausted = true;
responseBodyComplete();
return -1L;
}
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
if (this.closed) {
return;
}
if (!this.inputExhausted) {
responseBodyComplete();
}
this.closed = true;
}
}
}

View File

@@ -0,0 +1,7 @@
package okhttp3.internal.http2;
import java.io.IOException;
/* loaded from: classes5.dex */
public final class ConnectionShutdownException extends IOException {
}

View File

@@ -0,0 +1,31 @@
package okhttp3.internal.http2;
/* loaded from: classes5.dex */
public enum ErrorCode {
NO_ERROR(0),
PROTOCOL_ERROR(1),
INTERNAL_ERROR(2),
FLOW_CONTROL_ERROR(3),
REFUSED_STREAM(7),
CANCEL(8),
COMPRESSION_ERROR(9),
CONNECT_ERROR(10),
ENHANCE_YOUR_CALM(11),
INADEQUATE_SECURITY(12),
HTTP_1_1_REQUIRED(13);
public final int httpCode;
ErrorCode(int i) {
this.httpCode = i;
}
public static ErrorCode fromHttp2(int i) {
for (ErrorCode errorCode : values()) {
if (errorCode.httpCode == i) {
return errorCode;
}
}
return null;
}
}

View File

@@ -0,0 +1,49 @@
package okhttp3.internal.http2;
import com.facebook.internal.security.CertificateUtil;
import com.ironsource.mediationsdk.logger.IronSourceError;
import okhttp3.internal.Util;
import okio.ByteString;
/* loaded from: classes5.dex */
public final class Header {
public final int hpackSize;
public final ByteString name;
public final ByteString value;
public static final ByteString PSEUDO_PREFIX = ByteString.encodeUtf8(CertificateUtil.DELIMITER);
public static final ByteString RESPONSE_STATUS = ByteString.encodeUtf8(com.mbridge.msdk.thrid.okhttp.internal.http2.Header.RESPONSE_STATUS_UTF8);
public static final ByteString TARGET_METHOD = ByteString.encodeUtf8(com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_METHOD_UTF8);
public static final ByteString TARGET_PATH = ByteString.encodeUtf8(com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_PATH_UTF8);
public static final ByteString TARGET_SCHEME = ByteString.encodeUtf8(com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_SCHEME_UTF8);
public static final ByteString TARGET_AUTHORITY = ByteString.encodeUtf8(com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_AUTHORITY_UTF8);
public Header(String str, String str2) {
this(ByteString.encodeUtf8(str), ByteString.encodeUtf8(str2));
}
public Header(ByteString byteString, String str) {
this(byteString, ByteString.encodeUtf8(str));
}
public Header(ByteString byteString, ByteString byteString2) {
this.name = byteString;
this.value = byteString2;
this.hpackSize = byteString.size() + 32 + byteString2.size();
}
public boolean equals(Object obj) {
if (!(obj instanceof Header)) {
return false;
}
Header header = (Header) obj;
return this.name.equals(header.name) && this.value.equals(header.value);
}
public int hashCode() {
return ((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.name.hashCode()) * 31) + this.value.hashCode();
}
public String toString() {
return Util.format("%s: %s", this.name.utf8(), this.value.utf8());
}
}

View File

@@ -0,0 +1,499 @@
package okhttp3.internal.http2;
import com.ironsource.zk;
import com.mbridge.msdk.foundation.download.database.DownloadModel;
import com.mbridge.msdk.mbsignalcommon.commonwebview.ToolBar;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.jvm.internal.ByteCompanionObject;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import okio.Okio;
import okio.Source;
import org.apache.http.cookie.ClientCookie;
/* loaded from: classes5.dex */
public abstract class Hpack {
public static final Map NAME_TO_FIRST_INDEX;
public static final Header[] STATIC_HEADER_TABLE;
static {
Header header = new Header(Header.TARGET_AUTHORITY, "");
ByteString byteString = Header.TARGET_METHOD;
Header header2 = new Header(byteString, "GET");
Header header3 = new Header(byteString, "POST");
ByteString byteString2 = Header.TARGET_PATH;
Header header4 = new Header(byteString2, "/");
Header header5 = new Header(byteString2, "/index.html");
ByteString byteString3 = Header.TARGET_SCHEME;
Header header6 = new Header(byteString3, "http");
Header header7 = new Header(byteString3, "https");
ByteString byteString4 = Header.RESPONSE_STATUS;
STATIC_HEADER_TABLE = new Header[]{header, header2, header3, header4, header5, header6, header7, new Header(byteString4, "200"), new Header(byteString4, "204"), new Header(byteString4, "206"), new Header(byteString4, "304"), new Header(byteString4, "400"), new Header(byteString4, "404"), new Header(byteString4, "500"), new Header("accept-charset", ""), new Header("accept-encoding", "gzip, deflate"), new Header("accept-language", ""), new Header("accept-ranges", ""), new Header("accept", ""), new Header("access-control-allow-origin", ""), new Header("age", ""), new Header("allow", ""), new Header("authorization", ""), new Header("cache-control", ""), new Header("content-disposition", ""), new Header("content-encoding", ""), new Header("content-language", ""), new Header("content-length", ""), new Header("content-location", ""), new Header("content-range", ""), new Header("content-type", ""), new Header("cookie", ""), new Header("date", ""), new Header(DownloadModel.ETAG, ""), new Header("expect", ""), new Header(ClientCookie.EXPIRES_ATTR, ""), new Header("from", ""), new Header("host", ""), new Header("if-match", ""), new Header("if-modified-since", ""), new Header("if-none-match", ""), new Header("if-range", ""), new Header("if-unmodified-since", ""), new Header("last-modified", ""), new Header("link", ""), new Header("location", ""), new Header("max-forwards", ""), new Header("proxy-authenticate", ""), new Header("proxy-authorization", ""), new Header("range", ""), new Header("referer", ""), new Header(ToolBar.REFRESH, ""), new Header("retry-after", ""), new Header(zk.a, ""), new Header("set-cookie", ""), new Header("strict-transport-security", ""), new Header("transfer-encoding", ""), new Header("user-agent", ""), new Header("vary", ""), new Header("via", ""), new Header("www-authenticate", "")};
NAME_TO_FIRST_INDEX = nameToFirstIndex();
}
public static final class Reader {
public Header[] dynamicTable;
public int dynamicTableByteCount;
public int headerCount;
public final List headerList;
public final int headerTableSizeSetting;
public int maxDynamicTableByteCount;
public int nextHeaderIndex;
public final BufferedSource source;
public final int dynamicTableIndex(int i) {
return this.nextHeaderIndex + 1 + i;
}
public Reader(int i, Source source) {
this(i, i, source);
}
public Reader(int i, int i2, Source source) {
this.headerList = new ArrayList();
this.dynamicTable = new Header[8];
this.nextHeaderIndex = r0.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
this.headerTableSizeSetting = i;
this.maxDynamicTableByteCount = i2;
this.source = Okio.buffer(source);
}
public final void adjustDynamicTableByteCount() {
int i = this.maxDynamicTableByteCount;
int i2 = this.dynamicTableByteCount;
if (i < i2) {
if (i == 0) {
clearDynamicTable();
} else {
evictToRecoverBytes(i2 - i);
}
}
}
public final void clearDynamicTable() {
Arrays.fill(this.dynamicTable, (Object) null);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
}
public final int evictToRecoverBytes(int i) {
int i2;
int i3 = 0;
if (i > 0) {
int length = this.dynamicTable.length;
while (true) {
length--;
i2 = this.nextHeaderIndex;
if (length < i2 || i <= 0) {
break;
}
int i4 = this.dynamicTable[length].hpackSize;
i -= i4;
this.dynamicTableByteCount -= i4;
this.headerCount--;
i3++;
}
Header[] headerArr = this.dynamicTable;
System.arraycopy(headerArr, i2 + 1, headerArr, i2 + 1 + i3, this.headerCount);
this.nextHeaderIndex += i3;
}
return i3;
}
public void readHeaders() {
while (!this.source.exhausted()) {
byte readByte = this.source.readByte();
int i = readByte & 255;
if (i == 128) {
throw new IOException("index == 0");
}
if ((readByte & ByteCompanionObject.MIN_VALUE) == 128) {
readIndexedHeader(readInt(i, 127) - 1);
} else if (i == 64) {
readLiteralHeaderWithIncrementalIndexingNewName();
} else if ((readByte & 64) == 64) {
readLiteralHeaderWithIncrementalIndexingIndexedName(readInt(i, 63) - 1);
} else if ((readByte & 32) == 32) {
int readInt = readInt(i, 31);
this.maxDynamicTableByteCount = readInt;
if (readInt < 0 || readInt > this.headerTableSizeSetting) {
throw new IOException("Invalid dynamic table size update " + this.maxDynamicTableByteCount);
}
adjustDynamicTableByteCount();
} else if (i == 16 || i == 0) {
readLiteralHeaderWithoutIndexingNewName();
} else {
readLiteralHeaderWithoutIndexingIndexedName(readInt(i, 15) - 1);
}
}
}
public List getAndResetHeaderList() {
ArrayList arrayList = new ArrayList(this.headerList);
this.headerList.clear();
return arrayList;
}
public final void readIndexedHeader(int i) {
if (isStaticHeader(i)) {
this.headerList.add(Hpack.STATIC_HEADER_TABLE[i]);
return;
}
int dynamicTableIndex = dynamicTableIndex(i - Hpack.STATIC_HEADER_TABLE.length);
if (dynamicTableIndex >= 0) {
Header[] headerArr = this.dynamicTable;
if (dynamicTableIndex < headerArr.length) {
this.headerList.add(headerArr[dynamicTableIndex]);
return;
}
}
throw new IOException("Header index too large " + (i + 1));
}
public final void readLiteralHeaderWithoutIndexingIndexedName(int i) {
this.headerList.add(new Header(getName(i), readByteString()));
}
public final void readLiteralHeaderWithoutIndexingNewName() {
this.headerList.add(new Header(Hpack.checkLowercase(readByteString()), readByteString()));
}
public final void readLiteralHeaderWithIncrementalIndexingIndexedName(int i) {
insertIntoDynamicTable(-1, new Header(getName(i), readByteString()));
}
public final void readLiteralHeaderWithIncrementalIndexingNewName() {
insertIntoDynamicTable(-1, new Header(Hpack.checkLowercase(readByteString()), readByteString()));
}
public final ByteString getName(int i) {
if (isStaticHeader(i)) {
return Hpack.STATIC_HEADER_TABLE[i].name;
}
int dynamicTableIndex = dynamicTableIndex(i - Hpack.STATIC_HEADER_TABLE.length);
if (dynamicTableIndex >= 0) {
Header[] headerArr = this.dynamicTable;
if (dynamicTableIndex < headerArr.length) {
return headerArr[dynamicTableIndex].name;
}
}
throw new IOException("Header index too large " + (i + 1));
}
public final boolean isStaticHeader(int i) {
return i >= 0 && i <= Hpack.STATIC_HEADER_TABLE.length - 1;
}
public final void insertIntoDynamicTable(int i, Header header) {
this.headerList.add(header);
int i2 = header.hpackSize;
if (i != -1) {
i2 -= this.dynamicTable[dynamicTableIndex(i)].hpackSize;
}
int i3 = this.maxDynamicTableByteCount;
if (i2 > i3) {
clearDynamicTable();
return;
}
int evictToRecoverBytes = evictToRecoverBytes((this.dynamicTableByteCount + i2) - i3);
if (i == -1) {
int i4 = this.headerCount + 1;
Header[] headerArr = this.dynamicTable;
if (i4 > headerArr.length) {
Header[] headerArr2 = new Header[headerArr.length * 2];
System.arraycopy(headerArr, 0, headerArr2, headerArr.length, headerArr.length);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.dynamicTable = headerArr2;
}
int i5 = this.nextHeaderIndex;
this.nextHeaderIndex = i5 - 1;
this.dynamicTable[i5] = header;
this.headerCount++;
} else {
this.dynamicTable[i + dynamicTableIndex(i) + evictToRecoverBytes] = header;
}
this.dynamicTableByteCount += i2;
}
public final int readByte() {
return this.source.readByte() & 255;
}
public int readInt(int i, int i2) {
int i3 = i & i2;
if (i3 < i2) {
return i3;
}
int i4 = 0;
while (true) {
int readByte = readByte();
if ((readByte & 128) == 0) {
return i2 + (readByte << i4);
}
i2 += (readByte & 127) << i4;
i4 += 7;
}
}
public ByteString readByteString() {
int readByte = readByte();
boolean z = (readByte & 128) == 128;
int readInt = readInt(readByte, 127);
if (z) {
return ByteString.of(Huffman.get().decode(this.source.readByteArray(readInt)));
}
return this.source.readByteString(readInt);
}
}
public static Map nameToFirstIndex() {
LinkedHashMap linkedHashMap = new LinkedHashMap(STATIC_HEADER_TABLE.length);
int i = 0;
while (true) {
Header[] headerArr = STATIC_HEADER_TABLE;
if (i < headerArr.length) {
if (!linkedHashMap.containsKey(headerArr[i].name)) {
linkedHashMap.put(headerArr[i].name, Integer.valueOf(i));
}
i++;
} else {
return Collections.unmodifiableMap(linkedHashMap);
}
}
}
public static final class Writer {
public Header[] dynamicTable;
public int dynamicTableByteCount;
public boolean emitDynamicTableSizeUpdate;
public int headerCount;
public int headerTableSizeSetting;
public int maxDynamicTableByteCount;
public int nextHeaderIndex;
public final Buffer out;
public int smallestHeaderTableSizeSetting;
public final boolean useCompression;
public Writer(Buffer buffer) {
this(4096, true, buffer);
}
public Writer(int i, boolean z, Buffer buffer) {
this.smallestHeaderTableSizeSetting = Integer.MAX_VALUE;
this.dynamicTable = new Header[8];
this.nextHeaderIndex = r0.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
this.headerTableSizeSetting = i;
this.maxDynamicTableByteCount = i;
this.useCompression = z;
this.out = buffer;
}
public final void clearDynamicTable() {
Arrays.fill(this.dynamicTable, (Object) null);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
}
public final int evictToRecoverBytes(int i) {
int i2;
int i3 = 0;
if (i > 0) {
int length = this.dynamicTable.length;
while (true) {
length--;
i2 = this.nextHeaderIndex;
if (length < i2 || i <= 0) {
break;
}
int i4 = this.dynamicTable[length].hpackSize;
i -= i4;
this.dynamicTableByteCount -= i4;
this.headerCount--;
i3++;
}
Header[] headerArr = this.dynamicTable;
System.arraycopy(headerArr, i2 + 1, headerArr, i2 + 1 + i3, this.headerCount);
Header[] headerArr2 = this.dynamicTable;
int i5 = this.nextHeaderIndex;
Arrays.fill(headerArr2, i5 + 1, i5 + 1 + i3, (Object) null);
this.nextHeaderIndex += i3;
}
return i3;
}
public final void insertIntoDynamicTable(Header header) {
int i = header.hpackSize;
int i2 = this.maxDynamicTableByteCount;
if (i > i2) {
clearDynamicTable();
return;
}
evictToRecoverBytes((this.dynamicTableByteCount + i) - i2);
int i3 = this.headerCount + 1;
Header[] headerArr = this.dynamicTable;
if (i3 > headerArr.length) {
Header[] headerArr2 = new Header[headerArr.length * 2];
System.arraycopy(headerArr, 0, headerArr2, headerArr.length, headerArr.length);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.dynamicTable = headerArr2;
}
int i4 = this.nextHeaderIndex;
this.nextHeaderIndex = i4 - 1;
this.dynamicTable[i4] = header;
this.headerCount++;
this.dynamicTableByteCount += i;
}
public void writeHeaders(List list) {
int i;
int i2;
if (this.emitDynamicTableSizeUpdate) {
int i3 = this.smallestHeaderTableSizeSetting;
if (i3 < this.maxDynamicTableByteCount) {
writeInt(i3, 31, 32);
}
this.emitDynamicTableSizeUpdate = false;
this.smallestHeaderTableSizeSetting = Integer.MAX_VALUE;
writeInt(this.maxDynamicTableByteCount, 31, 32);
}
int size = list.size();
for (int i4 = 0; i4 < size; i4++) {
Header header = (Header) list.get(i4);
ByteString asciiLowercase = header.name.toAsciiLowercase();
ByteString byteString = header.value;
Integer num = (Integer) Hpack.NAME_TO_FIRST_INDEX.get(asciiLowercase);
if (num != null) {
int intValue = num.intValue();
i2 = intValue + 1;
if (i2 > 1 && i2 < 8) {
Header[] headerArr = Hpack.STATIC_HEADER_TABLE;
if (Objects.equals(headerArr[intValue].value, byteString)) {
i = i2;
} else if (Objects.equals(headerArr[i2].value, byteString)) {
i2 = intValue + 2;
i = i2;
}
}
i = i2;
i2 = -1;
} else {
i = -1;
i2 = -1;
}
if (i2 == -1) {
int i5 = this.nextHeaderIndex + 1;
int length = this.dynamicTable.length;
while (true) {
if (i5 >= length) {
break;
}
if (Objects.equals(this.dynamicTable[i5].name, asciiLowercase)) {
if (Objects.equals(this.dynamicTable[i5].value, byteString)) {
i2 = (i5 - this.nextHeaderIndex) + Hpack.STATIC_HEADER_TABLE.length;
break;
} else if (i == -1) {
i = (i5 - this.nextHeaderIndex) + Hpack.STATIC_HEADER_TABLE.length;
}
}
i5++;
}
}
if (i2 != -1) {
writeInt(i2, 127, 128);
} else if (i == -1) {
this.out.writeByte(64);
writeByteString(asciiLowercase);
writeByteString(byteString);
insertIntoDynamicTable(header);
} else if (asciiLowercase.startsWith(Header.PSEUDO_PREFIX) && !Header.TARGET_AUTHORITY.equals(asciiLowercase)) {
writeInt(i, 15, 0);
writeByteString(byteString);
} else {
writeInt(i, 63, 64);
writeByteString(byteString);
insertIntoDynamicTable(header);
}
}
}
public void writeInt(int i, int i2, int i3) {
if (i < i2) {
this.out.writeByte(i | i3);
return;
}
this.out.writeByte(i3 | i2);
int i4 = i - i2;
while (i4 >= 128) {
this.out.writeByte(128 | (i4 & 127));
i4 >>>= 7;
}
this.out.writeByte(i4);
}
public void writeByteString(ByteString byteString) {
if (this.useCompression && Huffman.get().encodedLength(byteString) < byteString.size()) {
Buffer buffer = new Buffer();
Huffman.get().encode(byteString, buffer);
ByteString readByteString = buffer.readByteString();
writeInt(readByteString.size(), 127, 128);
this.out.write(readByteString);
return;
}
writeInt(byteString.size(), 127, 0);
this.out.write(byteString);
}
public void setHeaderTableSizeSetting(int i) {
this.headerTableSizeSetting = i;
int min = Math.min(i, 16384);
int i2 = this.maxDynamicTableByteCount;
if (i2 == min) {
return;
}
if (min < i2) {
this.smallestHeaderTableSizeSetting = Math.min(this.smallestHeaderTableSizeSetting, min);
}
this.emitDynamicTableSizeUpdate = true;
this.maxDynamicTableByteCount = min;
adjustDynamicTableByteCount();
}
public final void adjustDynamicTableByteCount() {
int i = this.maxDynamicTableByteCount;
int i2 = this.dynamicTableByteCount;
if (i < i2) {
if (i == 0) {
clearDynamicTable();
} else {
evictToRecoverBytes(i2 - i);
}
}
}
}
public static ByteString checkLowercase(ByteString byteString) {
int size = byteString.size();
for (int i = 0; i < size; i++) {
byte b = byteString.getByte(i);
if (b >= 65 && b <= 90) {
throw new IOException("PROTOCOL_ERROR response malformed: mixed case name: " + byteString.utf8());
}
}
return byteString;
}
}

View File

@@ -0,0 +1,96 @@
package okhttp3.internal.http2;
import java.io.IOException;
import okhttp3.internal.Util;
import okio.ByteString;
/* loaded from: classes5.dex */
public abstract class Http2 {
public static final ByteString CONNECTION_PREFACE = ByteString.encodeUtf8("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");
public static final String[] FRAME_NAMES = {"DATA", "HEADERS", "PRIORITY", "RST_STREAM", "SETTINGS", "PUSH_PROMISE", "PING", "GOAWAY", "WINDOW_UPDATE", "CONTINUATION"};
public static final String[] FLAGS = new String[64];
public static final String[] BINARY = new String[256];
static {
int i = 0;
int i2 = 0;
while (true) {
String[] strArr = BINARY;
if (i2 >= strArr.length) {
break;
}
strArr[i2] = Util.format("%8s", Integer.toBinaryString(i2)).replace(' ', '0');
i2++;
}
String[] strArr2 = FLAGS;
strArr2[0] = "";
strArr2[1] = "END_STREAM";
int[] iArr = {1};
strArr2[8] = "PADDED";
int i3 = iArr[0];
strArr2[i3 | 8] = strArr2[i3] + "|PADDED";
strArr2[4] = "END_HEADERS";
strArr2[32] = "PRIORITY";
strArr2[36] = "END_HEADERS|PRIORITY";
int[] iArr2 = {4, 32, 36};
for (int i4 = 0; i4 < 3; i4++) {
int i5 = iArr2[i4];
int i6 = iArr[0];
String[] strArr3 = FLAGS;
int i7 = i6 | i5;
strArr3[i7] = strArr3[i6] + '|' + strArr3[i5];
strArr3[i7 | 8] = strArr3[i6] + '|' + strArr3[i5] + "|PADDED";
}
while (true) {
String[] strArr4 = FLAGS;
if (i >= strArr4.length) {
return;
}
if (strArr4[i] == null) {
strArr4[i] = BINARY[i];
}
i++;
}
}
public static IllegalArgumentException illegalArgument(String str, Object... objArr) {
throw new IllegalArgumentException(Util.format(str, objArr));
}
public static IOException ioException(String str, Object... objArr) {
throw new IOException(Util.format(str, objArr));
}
public static String frameLog(boolean z, int i, int i2, byte b, byte b2) {
String[] strArr = FRAME_NAMES;
String format = b < strArr.length ? strArr[b] : Util.format("0x%02x", Byte.valueOf(b));
String formatFlags = formatFlags(b, b2);
Object[] objArr = new Object[5];
objArr[0] = z ? "<<" : ">>";
objArr[1] = Integer.valueOf(i);
objArr[2] = Integer.valueOf(i2);
objArr[3] = format;
objArr[4] = formatFlags;
return Util.format("%s 0x%08x %5d %-13s %s", objArr);
}
public static String formatFlags(byte b, byte b2) {
if (b2 == 0) {
return "";
}
if (b != 2 && b != 3) {
if (b == 4 || b == 6) {
return b2 == 1 ? "ACK" : BINARY[b2];
}
if (b != 7 && b != 8) {
String[] strArr = FLAGS;
String str = b2 < strArr.length ? strArr[b2] : BINARY[b2];
if (b != 5 || (b2 & 4) == 0) {
return (b != 0 || (b2 & 32) == 0) ? str : str.replace("PRIORITY", "COMPRESSED");
}
return str.replace("HEADERS", "PUSH_PROMISE");
}
}
return BINARY[b2];
}
}

View File

@@ -0,0 +1,946 @@
package okhttp3.internal.http2;
import androidx.core.internal.view.SupportMenu;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import java.io.Closeable;
import java.io.IOException;
import java.net.Socket;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import okhttp3.internal.NamedRunnable;
import okhttp3.internal.Util;
import okhttp3.internal.http2.Http2Reader;
import okhttp3.internal.platform.Platform;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.ByteString;
/* loaded from: classes5.dex */
public final class Http2Connection implements Closeable {
public static final ExecutorService listenerExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue(), Util.threadFactory("OkHttp Http2Connection", true));
public long bytesLeftInWriteWindow;
public final boolean client;
public final String connectionName;
public final Set currentPushRequests;
public int lastGoodStreamId;
public final Listener listener;
public int nextStreamId;
public final Settings peerSettings;
public final ExecutorService pushExecutor;
public final PushObserver pushObserver;
public final ReaderRunnable readerRunnable;
public boolean shutdown;
public final Socket socket;
public final Http2Writer writer;
public final ScheduledExecutorService writerExecutor;
public final Map streams = new LinkedHashMap();
public long intervalPingsSent = 0;
public long intervalPongsReceived = 0;
public long degradedPingsSent = 0;
public long degradedPongsReceived = 0;
public long awaitPingsSent = 0;
public long awaitPongsReceived = 0;
public long degradedPongDeadlineNs = 0;
public long unacknowledgedBytesRead = 0;
public Settings okHttpSettings = new Settings();
public static abstract class Listener {
public static final Listener REFUSE_INCOMING_STREAMS = new Listener() { // from class: okhttp3.internal.http2.Http2Connection.Listener.1
@Override // okhttp3.internal.http2.Http2Connection.Listener
public void onStream(Http2Stream http2Stream) {
http2Stream.close(ErrorCode.REFUSED_STREAM, null);
}
};
public void onSettings(Http2Connection http2Connection) {
}
public abstract void onStream(Http2Stream http2Stream);
}
public boolean pushedStream(int i) {
return i != 0 && (i & 1) == 0;
}
public static /* synthetic */ long access$108(Http2Connection http2Connection) {
long j = http2Connection.intervalPongsReceived;
http2Connection.intervalPongsReceived = 1 + j;
return j;
}
public static /* synthetic */ long access$208(Http2Connection http2Connection) {
long j = http2Connection.intervalPingsSent;
http2Connection.intervalPingsSent = 1 + j;
return j;
}
public static /* synthetic */ long access$608(Http2Connection http2Connection) {
long j = http2Connection.degradedPongsReceived;
http2Connection.degradedPongsReceived = 1 + j;
return j;
}
public static /* synthetic */ long access$708(Http2Connection http2Connection) {
long j = http2Connection.awaitPongsReceived;
http2Connection.awaitPongsReceived = 1 + j;
return j;
}
public Http2Connection(Builder builder) {
Settings settings = new Settings();
this.peerSettings = settings;
this.currentPushRequests = new LinkedHashSet();
this.pushObserver = builder.pushObserver;
boolean z = builder.client;
this.client = z;
this.listener = builder.listener;
int i = z ? 1 : 2;
this.nextStreamId = i;
if (z) {
this.nextStreamId = i + 2;
}
if (z) {
this.okHttpSettings.set(7, 16777216);
}
String str = builder.connectionName;
this.connectionName = str;
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1, Util.threadFactory(Util.format("OkHttp %s Writer", str), false));
this.writerExecutor = scheduledThreadPoolExecutor;
if (builder.pingIntervalMillis != 0) {
IntervalPingRunnable intervalPingRunnable = new IntervalPingRunnable();
int i2 = builder.pingIntervalMillis;
scheduledThreadPoolExecutor.scheduleAtFixedRate(intervalPingRunnable, i2, i2, TimeUnit.MILLISECONDS);
}
this.pushExecutor = new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue(), Util.threadFactory(Util.format("OkHttp %s Push Observer", str), true));
settings.set(7, SupportMenu.USER_MASK);
settings.set(5, 16384);
this.bytesLeftInWriteWindow = settings.getInitialWindowSize();
this.socket = builder.socket;
this.writer = new Http2Writer(builder.sink, z);
this.readerRunnable = new ReaderRunnable(new Http2Reader(builder.source, z));
}
public synchronized Http2Stream getStream(int i) {
return (Http2Stream) this.streams.get(Integer.valueOf(i));
}
public synchronized Http2Stream removeStream(int i) {
Http2Stream http2Stream;
http2Stream = (Http2Stream) this.streams.remove(Integer.valueOf(i));
notifyAll();
return http2Stream;
}
public synchronized int maxConcurrentStreams() {
return this.peerSettings.getMaxConcurrentStreams(Integer.MAX_VALUE);
}
public synchronized void updateConnectionFlowControl(long j) {
long j2 = this.unacknowledgedBytesRead + j;
this.unacknowledgedBytesRead = j2;
if (j2 >= this.okHttpSettings.getInitialWindowSize() / 2) {
writeWindowUpdateLater(0, this.unacknowledgedBytesRead);
this.unacknowledgedBytesRead = 0L;
}
}
public Http2Stream newStream(List list, boolean z) {
return newStream(0, list, z);
}
/* JADX WARN: Removed duplicated region for block: B:21:0x0044 A[Catch: all -> 0x0014, TryCatch #0 {all -> 0x0014, blocks: (B:6:0x0007, B:8:0x000e, B:9:0x0016, B:11:0x001a, B:13:0x002c, B:15:0x0034, B:19:0x003e, B:21:0x0044, B:22:0x004d, B:36:0x0072, B:37:0x0077), top: B:5:0x0007, outer: #1 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final okhttp3.internal.http2.Http2Stream newStream(int r11, java.util.List r12, boolean r13) {
/*
r10 = this;
r6 = r13 ^ 1
r4 = 0
okhttp3.internal.http2.Http2Writer r7 = r10.writer
monitor-enter(r7)
monitor-enter(r10) // Catch: java.lang.Throwable -> L56
int r0 = r10.nextStreamId // Catch: java.lang.Throwable -> L14
r1 = 1073741823(0x3fffffff, float:1.9999999)
if (r0 <= r1) goto L16
okhttp3.internal.http2.ErrorCode r0 = okhttp3.internal.http2.ErrorCode.REFUSED_STREAM // Catch: java.lang.Throwable -> L14
r10.shutdown(r0) // Catch: java.lang.Throwable -> L14
goto L16
L14:
r11 = move-exception
goto L78
L16:
boolean r0 = r10.shutdown // Catch: java.lang.Throwable -> L14
if (r0 != 0) goto L72
int r8 = r10.nextStreamId // Catch: java.lang.Throwable -> L14
int r0 = r8 + 2
r10.nextStreamId = r0 // Catch: java.lang.Throwable -> L14
okhttp3.internal.http2.Http2Stream r9 = new okhttp3.internal.http2.Http2Stream // Catch: java.lang.Throwable -> L14
r5 = 0
r0 = r9
r1 = r8
r2 = r10
r3 = r6
r0.<init>(r1, r2, r3, r4, r5) // Catch: java.lang.Throwable -> L14
if (r13 == 0) goto L3d
long r0 = r10.bytesLeftInWriteWindow // Catch: java.lang.Throwable -> L14
r2 = 0
int r13 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
if (r13 == 0) goto L3d
long r0 = r9.bytesLeftInWriteWindow // Catch: java.lang.Throwable -> L14
int r13 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
if (r13 != 0) goto L3b
goto L3d
L3b:
r13 = 0
goto L3e
L3d:
r13 = 1
L3e:
boolean r0 = r9.isOpen() // Catch: java.lang.Throwable -> L14
if (r0 == 0) goto L4d
java.util.Map r0 = r10.streams // Catch: java.lang.Throwable -> L14
java.lang.Integer r1 = java.lang.Integer.valueOf(r8) // Catch: java.lang.Throwable -> L14
r0.put(r1, r9) // Catch: java.lang.Throwable -> L14
L4d:
monitor-exit(r10) // Catch: java.lang.Throwable -> L14
if (r11 != 0) goto L58
okhttp3.internal.http2.Http2Writer r11 = r10.writer // Catch: java.lang.Throwable -> L56
r11.headers(r6, r8, r12) // Catch: java.lang.Throwable -> L56
goto L61
L56:
r11 = move-exception
goto L7a
L58:
boolean r0 = r10.client // Catch: java.lang.Throwable -> L56
if (r0 != 0) goto L6a
okhttp3.internal.http2.Http2Writer r0 = r10.writer // Catch: java.lang.Throwable -> L56
r0.pushPromise(r11, r8, r12) // Catch: java.lang.Throwable -> L56
L61:
monitor-exit(r7) // Catch: java.lang.Throwable -> L56
if (r13 == 0) goto L69
okhttp3.internal.http2.Http2Writer r11 = r10.writer
r11.flush()
L69:
return r9
L6a:
java.lang.IllegalArgumentException r11 = new java.lang.IllegalArgumentException // Catch: java.lang.Throwable -> L56
java.lang.String r12 = "client streams shouldn't have associated stream IDs"
r11.<init>(r12) // Catch: java.lang.Throwable -> L56
throw r11 // Catch: java.lang.Throwable -> L56
L72:
okhttp3.internal.http2.ConnectionShutdownException r11 = new okhttp3.internal.http2.ConnectionShutdownException // Catch: java.lang.Throwable -> L14
r11.<init>() // Catch: java.lang.Throwable -> L14
throw r11 // Catch: java.lang.Throwable -> L14
L78:
monitor-exit(r10) // Catch: java.lang.Throwable -> L14
throw r11 // Catch: java.lang.Throwable -> L56
L7a:
monitor-exit(r7) // Catch: java.lang.Throwable -> L56
throw r11
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.http2.Http2Connection.newStream(int, java.util.List, boolean):okhttp3.internal.http2.Http2Stream");
}
public void writeHeaders(int i, boolean z, List list) {
this.writer.headers(z, i, list);
}
/* JADX WARN: Code restructure failed: missing block: B:20:0x0032, code lost:
r2 = java.lang.Math.min((int) java.lang.Math.min(r12, r4), r8.writer.maxDataLength());
r6 = r2;
r8.bytesLeftInWriteWindow -= r6;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void writeData(int r9, boolean r10, okio.Buffer r11, long r12) {
/*
r8 = this;
r0 = 0
int r2 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
r3 = 0
if (r2 != 0) goto Ld
okhttp3.internal.http2.Http2Writer r12 = r8.writer
r12.data(r10, r9, r11, r3)
return
Ld:
int r2 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
if (r2 <= 0) goto L67
monitor-enter(r8)
L12:
long r4 = r8.bytesLeftInWriteWindow // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
int r2 = (r4 > r0 ? 1 : (r4 == r0 ? 0 : -1))
if (r2 > 0) goto L32
java.util.Map r2 = r8.streams // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
java.lang.Integer r4 = java.lang.Integer.valueOf(r9) // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
boolean r2 = r2.containsKey(r4) // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
if (r2 == 0) goto L2a
r8.wait() // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
goto L12
L28:
r9 = move-exception
goto L65
L2a:
java.io.IOException r9 = new java.io.IOException // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
java.lang.String r10 = "stream closed"
r9.<init>(r10) // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
throw r9 // Catch: java.lang.Throwable -> L28 java.lang.InterruptedException -> L58
L32:
long r4 = java.lang.Math.min(r12, r4) // Catch: java.lang.Throwable -> L28
int r2 = (int) r4 // Catch: java.lang.Throwable -> L28
okhttp3.internal.http2.Http2Writer r4 = r8.writer // Catch: java.lang.Throwable -> L28
int r4 = r4.maxDataLength() // Catch: java.lang.Throwable -> L28
int r2 = java.lang.Math.min(r2, r4) // Catch: java.lang.Throwable -> L28
long r4 = r8.bytesLeftInWriteWindow // Catch: java.lang.Throwable -> L28
long r6 = (long) r2 // Catch: java.lang.Throwable -> L28
long r4 = r4 - r6
r8.bytesLeftInWriteWindow = r4 // Catch: java.lang.Throwable -> L28
monitor-exit(r8) // Catch: java.lang.Throwable -> L28
long r12 = r12 - r6
okhttp3.internal.http2.Http2Writer r4 = r8.writer
if (r10 == 0) goto L53
int r5 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
if (r5 != 0) goto L53
r5 = 1
goto L54
L53:
r5 = r3
L54:
r4.data(r5, r9, r11, r2)
goto Ld
L58:
java.lang.Thread r9 = java.lang.Thread.currentThread() // Catch: java.lang.Throwable -> L28
r9.interrupt() // Catch: java.lang.Throwable -> L28
java.io.InterruptedIOException r9 = new java.io.InterruptedIOException // Catch: java.lang.Throwable -> L28
r9.<init>() // Catch: java.lang.Throwable -> L28
throw r9 // Catch: java.lang.Throwable -> L28
L65:
monitor-exit(r8) // Catch: java.lang.Throwable -> L28
throw r9
L67:
return
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.http2.Http2Connection.writeData(int, boolean, okio.Buffer, long):void");
}
public void writeSynResetLater(final int i, final ErrorCode errorCode) {
try {
this.writerExecutor.execute(new NamedRunnable("OkHttp %s stream %d", new Object[]{this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.1
@Override // okhttp3.internal.NamedRunnable
public void execute() {
try {
Http2Connection.this.writeSynReset(i, errorCode);
} catch (IOException e) {
Http2Connection.this.failConnection(e);
}
}
});
} catch (RejectedExecutionException unused) {
}
}
public void writeSynReset(int i, ErrorCode errorCode) {
this.writer.rstStream(i, errorCode);
}
public void writeWindowUpdateLater(final int i, final long j) {
try {
this.writerExecutor.execute(new NamedRunnable("OkHttp Window Update %s stream %d", new Object[]{this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.2
@Override // okhttp3.internal.NamedRunnable
public void execute() {
try {
Http2Connection.this.writer.windowUpdate(i, j);
} catch (IOException e) {
Http2Connection.this.failConnection(e);
}
}
});
} catch (RejectedExecutionException unused) {
}
}
public final class PingRunnable extends NamedRunnable {
public final int payload1;
public final int payload2;
public final boolean reply;
public PingRunnable(boolean z, int i, int i2) {
super("OkHttp %s ping %08x%08x", Http2Connection.this.connectionName, Integer.valueOf(i), Integer.valueOf(i2));
this.reply = z;
this.payload1 = i;
this.payload2 = i2;
}
@Override // okhttp3.internal.NamedRunnable
public void execute() {
Http2Connection.this.writePing(this.reply, this.payload1, this.payload2);
}
}
public final class IntervalPingRunnable extends NamedRunnable {
public IntervalPingRunnable() {
super("OkHttp %s ping", Http2Connection.this.connectionName);
}
@Override // okhttp3.internal.NamedRunnable
public void execute() {
boolean z;
synchronized (Http2Connection.this) {
if (Http2Connection.this.intervalPongsReceived < Http2Connection.this.intervalPingsSent) {
z = true;
} else {
Http2Connection.access$208(Http2Connection.this);
z = false;
}
}
if (z) {
Http2Connection.this.failConnection(null);
} else {
Http2Connection.this.writePing(false, 1, 0);
}
}
}
public void writePing(boolean z, int i, int i2) {
try {
this.writer.ping(z, i, i2);
} catch (IOException e) {
failConnection(e);
}
}
public void flush() {
this.writer.flush();
}
public void shutdown(ErrorCode errorCode) {
synchronized (this.writer) {
synchronized (this) {
if (this.shutdown) {
return;
}
this.shutdown = true;
this.writer.goAway(this.lastGoodStreamId, errorCode, Util.EMPTY_BYTE_ARRAY);
}
}
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() {
close(ErrorCode.NO_ERROR, ErrorCode.CANCEL, null);
}
public void close(ErrorCode errorCode, ErrorCode errorCode2, IOException iOException) {
Http2Stream[] http2StreamArr;
try {
shutdown(errorCode);
} catch (IOException unused) {
}
synchronized (this) {
try {
if (this.streams.isEmpty()) {
http2StreamArr = null;
} else {
http2StreamArr = (Http2Stream[]) this.streams.values().toArray(new Http2Stream[this.streams.size()]);
this.streams.clear();
}
} catch (Throwable th) {
throw th;
}
}
if (http2StreamArr != null) {
for (Http2Stream http2Stream : http2StreamArr) {
try {
http2Stream.close(errorCode2, iOException);
} catch (IOException unused2) {
}
}
}
try {
this.writer.close();
} catch (IOException unused3) {
}
try {
this.socket.close();
} catch (IOException unused4) {
}
this.writerExecutor.shutdown();
this.pushExecutor.shutdown();
}
public final void failConnection(IOException iOException) {
ErrorCode errorCode = ErrorCode.PROTOCOL_ERROR;
close(errorCode, errorCode, iOException);
}
public void start() {
start(true);
}
public void start(boolean z) {
if (z) {
this.writer.connectionPreface();
this.writer.settings(this.okHttpSettings);
if (this.okHttpSettings.getInitialWindowSize() != 65535) {
this.writer.windowUpdate(0, r5 - SupportMenu.USER_MASK);
}
}
new Thread(this.readerRunnable).start();
}
public synchronized boolean isHealthy(long j) {
if (this.shutdown) {
return false;
}
if (this.degradedPongsReceived < this.degradedPingsSent) {
if (j >= this.degradedPongDeadlineNs) {
return false;
}
}
return true;
}
public void sendDegradedPingLater() {
synchronized (this) {
try {
long j = this.degradedPongsReceived;
long j2 = this.degradedPingsSent;
if (j < j2) {
return;
}
this.degradedPingsSent = j2 + 1;
this.degradedPongDeadlineNs = System.nanoTime() + C.NANOS_PER_SECOND;
try {
this.writerExecutor.execute(new NamedRunnable("OkHttp %s ping", this.connectionName) { // from class: okhttp3.internal.http2.Http2Connection.3
@Override // okhttp3.internal.NamedRunnable
public void execute() {
Http2Connection.this.writePing(false, 2, 0);
}
});
} catch (RejectedExecutionException unused) {
}
} catch (Throwable th) {
throw th;
}
}
}
public static class Builder {
public boolean client;
public String connectionName;
public int pingIntervalMillis;
public BufferedSink sink;
public Socket socket;
public BufferedSource source;
public Listener listener = Listener.REFUSE_INCOMING_STREAMS;
public PushObserver pushObserver = PushObserver.CANCEL;
public Builder listener(Listener listener) {
this.listener = listener;
return this;
}
public Builder pingIntervalMillis(int i) {
this.pingIntervalMillis = i;
return this;
}
public Builder socket(Socket socket, String str, BufferedSource bufferedSource, BufferedSink bufferedSink) {
this.socket = socket;
this.connectionName = str;
this.source = bufferedSource;
this.sink = bufferedSink;
return this;
}
public Builder(boolean z) {
this.client = z;
}
public Http2Connection build() {
return new Http2Connection(this);
}
}
public class ReaderRunnable extends NamedRunnable implements Http2Reader.Handler {
public final Http2Reader reader;
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void ackSettings() {
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void priority(int i, int i2, int i3, boolean z) {
}
public ReaderRunnable(Http2Reader http2Reader) {
super("OkHttp %s", Http2Connection.this.connectionName);
this.reader = http2Reader;
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r0v0, types: [okhttp3.internal.http2.ErrorCode] */
/* JADX WARN: Type inference failed for: r0v3 */
/* JADX WARN: Type inference failed for: r0v5, types: [java.io.Closeable, okhttp3.internal.http2.Http2Reader] */
@Override // okhttp3.internal.NamedRunnable
public void execute() {
ErrorCode errorCode;
ErrorCode errorCode2 = ErrorCode.INTERNAL_ERROR;
IOException e = null;
try {
try {
this.reader.readConnectionPreface(this);
while (this.reader.nextFrame(false, this)) {
}
ErrorCode errorCode3 = ErrorCode.NO_ERROR;
try {
Http2Connection.this.close(errorCode3, ErrorCode.CANCEL, null);
errorCode = errorCode3;
} catch (IOException e2) {
e = e2;
ErrorCode errorCode4 = ErrorCode.PROTOCOL_ERROR;
Http2Connection http2Connection = Http2Connection.this;
http2Connection.close(errorCode4, errorCode4, e);
errorCode = http2Connection;
errorCode2 = this.reader;
Util.closeQuietly((Closeable) errorCode2);
}
} catch (Throwable th) {
th = th;
Http2Connection.this.close(errorCode, errorCode2, e);
Util.closeQuietly(this.reader);
throw th;
}
} catch (IOException e3) {
e = e3;
} catch (Throwable th2) {
th = th2;
errorCode = errorCode2;
Http2Connection.this.close(errorCode, errorCode2, e);
Util.closeQuietly(this.reader);
throw th;
}
errorCode2 = this.reader;
Util.closeQuietly((Closeable) errorCode2);
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void data(boolean z, int i, BufferedSource bufferedSource, int i2) {
if (Http2Connection.this.pushedStream(i)) {
Http2Connection.this.pushDataLater(i, bufferedSource, i2, z);
return;
}
Http2Stream stream = Http2Connection.this.getStream(i);
if (stream == null) {
Http2Connection.this.writeSynResetLater(i, ErrorCode.PROTOCOL_ERROR);
long j = i2;
Http2Connection.this.updateConnectionFlowControl(j);
bufferedSource.skip(j);
return;
}
stream.receiveData(bufferedSource, i2);
if (z) {
stream.receiveHeaders(Util.EMPTY_HEADERS, true);
}
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void headers(boolean z, int i, int i2, List list) {
if (Http2Connection.this.pushedStream(i)) {
Http2Connection.this.pushHeadersLater(i, list, z);
return;
}
synchronized (Http2Connection.this) {
try {
Http2Stream stream = Http2Connection.this.getStream(i);
if (stream == null) {
if (Http2Connection.this.shutdown) {
return;
}
Http2Connection http2Connection = Http2Connection.this;
if (i <= http2Connection.lastGoodStreamId) {
return;
}
if (i % 2 == http2Connection.nextStreamId % 2) {
return;
}
final Http2Stream http2Stream = new Http2Stream(i, Http2Connection.this, false, z, Util.toHeaders(list));
Http2Connection http2Connection2 = Http2Connection.this;
http2Connection2.lastGoodStreamId = i;
http2Connection2.streams.put(Integer.valueOf(i), http2Stream);
Http2Connection.listenerExecutor.execute(new NamedRunnable("OkHttp %s stream %d", new Object[]{Http2Connection.this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.ReaderRunnable.1
@Override // okhttp3.internal.NamedRunnable
public void execute() {
try {
Http2Connection.this.listener.onStream(http2Stream);
} catch (IOException e) {
Platform.get().log(4, "Http2Connection.Listener failure for " + Http2Connection.this.connectionName, e);
try {
http2Stream.close(ErrorCode.PROTOCOL_ERROR, e);
} catch (IOException unused) {
}
}
}
});
return;
}
stream.receiveHeaders(Util.toHeaders(list), z);
} catch (Throwable th) {
throw th;
}
}
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void rstStream(int i, ErrorCode errorCode) {
if (Http2Connection.this.pushedStream(i)) {
Http2Connection.this.pushResetLater(i, errorCode);
return;
}
Http2Stream removeStream = Http2Connection.this.removeStream(i);
if (removeStream != null) {
removeStream.receiveRstStream(errorCode);
}
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void settings(final boolean z, final Settings settings) {
try {
Http2Connection.this.writerExecutor.execute(new NamedRunnable("OkHttp %s ACK Settings", new Object[]{Http2Connection.this.connectionName}) { // from class: okhttp3.internal.http2.Http2Connection.ReaderRunnable.2
@Override // okhttp3.internal.NamedRunnable
public void execute() {
ReaderRunnable.this.applyAndAckSettings(z, settings);
}
});
} catch (RejectedExecutionException unused) {
}
}
public void applyAndAckSettings(boolean z, Settings settings) {
Http2Stream[] http2StreamArr;
long j;
synchronized (Http2Connection.this.writer) {
synchronized (Http2Connection.this) {
try {
int initialWindowSize = Http2Connection.this.peerSettings.getInitialWindowSize();
if (z) {
Http2Connection.this.peerSettings.clear();
}
Http2Connection.this.peerSettings.merge(settings);
int initialWindowSize2 = Http2Connection.this.peerSettings.getInitialWindowSize();
http2StreamArr = null;
if (initialWindowSize2 == -1 || initialWindowSize2 == initialWindowSize) {
j = 0;
} else {
j = initialWindowSize2 - initialWindowSize;
if (!Http2Connection.this.streams.isEmpty()) {
http2StreamArr = (Http2Stream[]) Http2Connection.this.streams.values().toArray(new Http2Stream[Http2Connection.this.streams.size()]);
}
}
} finally {
}
}
try {
Http2Connection http2Connection = Http2Connection.this;
http2Connection.writer.applyAndAckSettings(http2Connection.peerSettings);
} catch (IOException e) {
Http2Connection.this.failConnection(e);
}
}
if (http2StreamArr != null) {
for (Http2Stream http2Stream : http2StreamArr) {
synchronized (http2Stream) {
http2Stream.addBytesToWriteWindow(j);
}
}
}
Http2Connection.listenerExecutor.execute(new NamedRunnable("OkHttp %s settings", Http2Connection.this.connectionName) { // from class: okhttp3.internal.http2.Http2Connection.ReaderRunnable.3
@Override // okhttp3.internal.NamedRunnable
public void execute() {
Http2Connection http2Connection2 = Http2Connection.this;
http2Connection2.listener.onSettings(http2Connection2);
}
});
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void ping(boolean z, int i, int i2) {
if (!z) {
try {
Http2Connection.this.writerExecutor.execute(Http2Connection.this.new PingRunnable(true, i, i2));
return;
} catch (RejectedExecutionException unused) {
return;
}
}
synchronized (Http2Connection.this) {
try {
if (i == 1) {
Http2Connection.access$108(Http2Connection.this);
} else if (i == 2) {
Http2Connection.access$608(Http2Connection.this);
} else if (i == 3) {
Http2Connection.access$708(Http2Connection.this);
Http2Connection.this.notifyAll();
}
} finally {
}
}
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void goAway(int i, ErrorCode errorCode, ByteString byteString) {
Http2Stream[] http2StreamArr;
byteString.size();
synchronized (Http2Connection.this) {
http2StreamArr = (Http2Stream[]) Http2Connection.this.streams.values().toArray(new Http2Stream[Http2Connection.this.streams.size()]);
Http2Connection.this.shutdown = true;
}
for (Http2Stream http2Stream : http2StreamArr) {
if (http2Stream.getId() > i && http2Stream.isLocallyInitiated()) {
http2Stream.receiveRstStream(ErrorCode.REFUSED_STREAM);
Http2Connection.this.removeStream(http2Stream.getId());
}
}
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void windowUpdate(int i, long j) {
if (i == 0) {
synchronized (Http2Connection.this) {
Http2Connection http2Connection = Http2Connection.this;
http2Connection.bytesLeftInWriteWindow += j;
http2Connection.notifyAll();
}
return;
}
Http2Stream stream = Http2Connection.this.getStream(i);
if (stream != null) {
synchronized (stream) {
stream.addBytesToWriteWindow(j);
}
}
}
@Override // okhttp3.internal.http2.Http2Reader.Handler
public void pushPromise(int i, int i2, List list) {
Http2Connection.this.pushRequestLater(i2, list);
}
}
public void pushRequestLater(final int i, final List list) {
synchronized (this) {
try {
if (this.currentPushRequests.contains(Integer.valueOf(i))) {
writeSynResetLater(i, ErrorCode.PROTOCOL_ERROR);
return;
}
this.currentPushRequests.add(Integer.valueOf(i));
try {
pushExecutorExecute(new NamedRunnable("OkHttp %s Push Request[%s]", new Object[]{this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.4
@Override // okhttp3.internal.NamedRunnable
public void execute() {
if (Http2Connection.this.pushObserver.onRequest(i, list)) {
try {
Http2Connection.this.writer.rstStream(i, ErrorCode.CANCEL);
synchronized (Http2Connection.this) {
Http2Connection.this.currentPushRequests.remove(Integer.valueOf(i));
}
} catch (IOException unused) {
}
}
}
});
} catch (RejectedExecutionException unused) {
}
} catch (Throwable th) {
throw th;
}
}
}
public void pushHeadersLater(final int i, final List list, final boolean z) {
try {
pushExecutorExecute(new NamedRunnable("OkHttp %s Push Headers[%s]", new Object[]{this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.5
@Override // okhttp3.internal.NamedRunnable
public void execute() {
boolean onHeaders = Http2Connection.this.pushObserver.onHeaders(i, list, z);
if (onHeaders) {
try {
Http2Connection.this.writer.rstStream(i, ErrorCode.CANCEL);
} catch (IOException unused) {
return;
}
}
if (onHeaders || z) {
synchronized (Http2Connection.this) {
Http2Connection.this.currentPushRequests.remove(Integer.valueOf(i));
}
}
}
});
} catch (RejectedExecutionException unused) {
}
}
public void pushDataLater(final int i, BufferedSource bufferedSource, final int i2, final boolean z) {
final Buffer buffer = new Buffer();
long j = i2;
bufferedSource.require(j);
bufferedSource.read(buffer, j);
if (buffer.size() != j) {
throw new IOException(buffer.size() + " != " + i2);
}
pushExecutorExecute(new NamedRunnable("OkHttp %s Push Data[%s]", new Object[]{this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.6
@Override // okhttp3.internal.NamedRunnable
public void execute() {
try {
boolean onData = Http2Connection.this.pushObserver.onData(i, buffer, i2, z);
if (onData) {
Http2Connection.this.writer.rstStream(i, ErrorCode.CANCEL);
}
if (onData || z) {
synchronized (Http2Connection.this) {
Http2Connection.this.currentPushRequests.remove(Integer.valueOf(i));
}
}
} catch (IOException unused) {
}
}
});
}
public void pushResetLater(final int i, final ErrorCode errorCode) {
pushExecutorExecute(new NamedRunnable("OkHttp %s Push Reset[%s]", new Object[]{this.connectionName, Integer.valueOf(i)}) { // from class: okhttp3.internal.http2.Http2Connection.7
@Override // okhttp3.internal.NamedRunnable
public void execute() {
Http2Connection.this.pushObserver.onReset(i, errorCode);
synchronized (Http2Connection.this) {
Http2Connection.this.currentPushRequests.remove(Integer.valueOf(i));
}
}
});
}
public final synchronized void pushExecutorExecute(NamedRunnable namedRunnable) {
if (!this.shutdown) {
this.pushExecutor.execute(namedRunnable);
}
}
}

View File

@@ -0,0 +1,149 @@
package okhttp3.internal.http2;
import java.io.IOException;
import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.internal.Internal;
import okhttp3.internal.Util;
import okhttp3.internal.connection.RealConnection;
import okhttp3.internal.http.ExchangeCodec;
import okhttp3.internal.http.HttpHeaders;
import okhttp3.internal.http.RequestLine;
import okhttp3.internal.http.StatusLine;
import okio.Sink;
import okio.Source;
import okio.Timeout;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class Http2ExchangeCodec implements ExchangeCodec {
public static final List HTTP_2_SKIPPED_REQUEST_HEADERS = Util.immutableList("connection", "host", "keep-alive", "proxy-connection", "te", "transfer-encoding", "encoding", "upgrade", com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_METHOD_UTF8, com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_PATH_UTF8, com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_SCHEME_UTF8, com.mbridge.msdk.thrid.okhttp.internal.http2.Header.TARGET_AUTHORITY_UTF8);
public static final List HTTP_2_SKIPPED_RESPONSE_HEADERS = Util.immutableList("connection", "host", "keep-alive", "proxy-connection", "te", "transfer-encoding", "encoding", "upgrade");
public volatile boolean canceled;
public final Interceptor.Chain chain;
public final Http2Connection connection;
public final Protocol protocol;
public final RealConnection realConnection;
public volatile Http2Stream stream;
@Override // okhttp3.internal.http.ExchangeCodec
public RealConnection connection() {
return this.realConnection;
}
public Http2ExchangeCodec(OkHttpClient okHttpClient, RealConnection realConnection, Interceptor.Chain chain, Http2Connection http2Connection) {
this.realConnection = realConnection;
this.chain = chain;
this.connection = http2Connection;
List protocols = okHttpClient.protocols();
Protocol protocol = Protocol.H2_PRIOR_KNOWLEDGE;
this.protocol = protocols.contains(protocol) ? protocol : Protocol.HTTP_2;
}
@Override // okhttp3.internal.http.ExchangeCodec
public Sink createRequestBody(Request request, long j) {
return this.stream.getSink();
}
@Override // okhttp3.internal.http.ExchangeCodec
public void writeRequestHeaders(Request request) {
if (this.stream != null) {
return;
}
this.stream = this.connection.newStream(http2HeadersList(request), request.body() != null);
if (this.canceled) {
this.stream.closeLater(ErrorCode.CANCEL);
throw new IOException("Canceled");
}
Timeout readTimeout = this.stream.readTimeout();
long readTimeoutMillis = this.chain.readTimeoutMillis();
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
readTimeout.timeout(readTimeoutMillis, timeUnit);
this.stream.writeTimeout().timeout(this.chain.writeTimeoutMillis(), timeUnit);
}
@Override // okhttp3.internal.http.ExchangeCodec
public void flushRequest() {
this.connection.flush();
}
@Override // okhttp3.internal.http.ExchangeCodec
public void finishRequest() {
this.stream.getSink().close();
}
@Override // okhttp3.internal.http.ExchangeCodec
public Response.Builder readResponseHeaders(boolean z) {
Response.Builder readHttp2HeadersList = readHttp2HeadersList(this.stream.takeHeaders(), this.protocol);
if (z && Internal.instance.code(readHttp2HeadersList) == 100) {
return null;
}
return readHttp2HeadersList;
}
public static List http2HeadersList(Request request) {
Headers headers = request.headers();
ArrayList arrayList = new ArrayList(headers.size() + 4);
arrayList.add(new Header(Header.TARGET_METHOD, request.method()));
arrayList.add(new Header(Header.TARGET_PATH, RequestLine.requestPath(request.url())));
String header = request.header(HTTP.TARGET_HOST);
if (header != null) {
arrayList.add(new Header(Header.TARGET_AUTHORITY, header));
}
arrayList.add(new Header(Header.TARGET_SCHEME, request.url().scheme()));
int size = headers.size();
for (int i = 0; i < size; i++) {
String lowerCase = headers.name(i).toLowerCase(Locale.US);
if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(lowerCase) || (lowerCase.equals("te") && headers.value(i).equals("trailers"))) {
arrayList.add(new Header(lowerCase, headers.value(i)));
}
}
return arrayList;
}
public static Response.Builder readHttp2HeadersList(Headers headers, Protocol protocol) {
Headers.Builder builder = new Headers.Builder();
int size = headers.size();
StatusLine statusLine = null;
for (int i = 0; i < size; i++) {
String name = headers.name(i);
String value = headers.value(i);
if (name.equals(com.mbridge.msdk.thrid.okhttp.internal.http2.Header.RESPONSE_STATUS_UTF8)) {
statusLine = StatusLine.parse("HTTP/1.1 " + value);
} else if (!HTTP_2_SKIPPED_RESPONSE_HEADERS.contains(name)) {
Internal.instance.addLenient(builder, name, value);
}
}
if (statusLine == null) {
throw new ProtocolException("Expected ':status' header not present");
}
return new Response.Builder().protocol(protocol).code(statusLine.code).message(statusLine.message).headers(builder.build());
}
@Override // okhttp3.internal.http.ExchangeCodec
public long reportedContentLength(Response response) {
return HttpHeaders.contentLength(response);
}
@Override // okhttp3.internal.http.ExchangeCodec
public Source openResponseBodySource(Response response) {
return this.stream.getSource();
}
@Override // okhttp3.internal.http.ExchangeCodec
public void cancel() {
this.canceled = true;
if (this.stream != null) {
this.stream.closeLater(ErrorCode.CANCEL);
}
}
}

View File

@@ -0,0 +1,364 @@
package okhttp3.internal.http2;
import java.io.Closeable;
import java.io.EOFException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import okhttp3.internal.Util;
import okhttp3.internal.http2.Hpack;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import okio.Source;
import okio.Timeout;
/* loaded from: classes5.dex */
public final class Http2Reader implements Closeable {
public static final Logger logger = Logger.getLogger(Http2.class.getName());
public final boolean client;
public final ContinuationSource continuation;
public final Hpack.Reader hpackReader;
public final BufferedSource source;
public interface Handler {
void ackSettings();
void data(boolean z, int i, BufferedSource bufferedSource, int i2);
void goAway(int i, ErrorCode errorCode, ByteString byteString);
void headers(boolean z, int i, int i2, List list);
void ping(boolean z, int i, int i2);
void priority(int i, int i2, int i3, boolean z);
void pushPromise(int i, int i2, List list);
void rstStream(int i, ErrorCode errorCode);
void settings(boolean z, Settings settings);
void windowUpdate(int i, long j);
}
public Http2Reader(BufferedSource bufferedSource, boolean z) {
this.source = bufferedSource;
this.client = z;
ContinuationSource continuationSource = new ContinuationSource(bufferedSource);
this.continuation = continuationSource;
this.hpackReader = new Hpack.Reader(4096, continuationSource);
}
public void readConnectionPreface(Handler handler) {
if (this.client) {
if (!nextFrame(true, handler)) {
throw Http2.ioException("Required SETTINGS preface not received", new Object[0]);
}
return;
}
BufferedSource bufferedSource = this.source;
ByteString byteString = Http2.CONNECTION_PREFACE;
ByteString readByteString = bufferedSource.readByteString(byteString.size());
Logger logger2 = logger;
if (logger2.isLoggable(Level.FINE)) {
logger2.fine(Util.format("<< CONNECTION %s", readByteString.hex()));
}
if (!byteString.equals(readByteString)) {
throw Http2.ioException("Expected a connection header but was %s", readByteString.utf8());
}
}
public boolean nextFrame(boolean z, Handler handler) {
try {
this.source.require(9L);
int readMedium = readMedium(this.source);
if (readMedium < 0 || readMedium > 16384) {
throw Http2.ioException("FRAME_SIZE_ERROR: %s", Integer.valueOf(readMedium));
}
byte readByte = (byte) (this.source.readByte() & 255);
if (z && readByte != 4) {
throw Http2.ioException("Expected a SETTINGS frame but was %s", Byte.valueOf(readByte));
}
byte readByte2 = (byte) (this.source.readByte() & 255);
int readInt = this.source.readInt() & Integer.MAX_VALUE;
Logger logger2 = logger;
if (logger2.isLoggable(Level.FINE)) {
logger2.fine(Http2.frameLog(true, readInt, readMedium, readByte, readByte2));
}
switch (readByte) {
case 0:
readData(handler, readMedium, readByte2, readInt);
return true;
case 1:
readHeaders(handler, readMedium, readByte2, readInt);
return true;
case 2:
readPriority(handler, readMedium, readByte2, readInt);
return true;
case 3:
readRstStream(handler, readMedium, readByte2, readInt);
return true;
case 4:
readSettings(handler, readMedium, readByte2, readInt);
return true;
case 5:
readPushPromise(handler, readMedium, readByte2, readInt);
return true;
case 6:
readPing(handler, readMedium, readByte2, readInt);
return true;
case 7:
readGoAway(handler, readMedium, readByte2, readInt);
return true;
case 8:
readWindowUpdate(handler, readMedium, readByte2, readInt);
return true;
default:
this.source.skip(readMedium);
return true;
}
} catch (EOFException unused) {
return false;
}
}
public final void readHeaders(Handler handler, int i, byte b, int i2) {
if (i2 == 0) {
throw Http2.ioException("PROTOCOL_ERROR: TYPE_HEADERS streamId == 0", new Object[0]);
}
boolean z = (b & 1) != 0;
short readByte = (b & 8) != 0 ? (short) (this.source.readByte() & 255) : (short) 0;
if ((b & 32) != 0) {
readPriority(handler, i2);
i -= 5;
}
handler.headers(z, i2, -1, readHeaderBlock(lengthWithoutPadding(i, b, readByte), readByte, b, i2));
}
public final List readHeaderBlock(int i, short s, byte b, int i2) {
ContinuationSource continuationSource = this.continuation;
continuationSource.left = i;
continuationSource.length = i;
continuationSource.padding = s;
continuationSource.flags = b;
continuationSource.streamId = i2;
this.hpackReader.readHeaders();
return this.hpackReader.getAndResetHeaderList();
}
public final void readData(Handler handler, int i, byte b, int i2) {
if (i2 == 0) {
throw Http2.ioException("PROTOCOL_ERROR: TYPE_DATA streamId == 0", new Object[0]);
}
boolean z = (b & 1) != 0;
if ((b & 32) != 0) {
throw Http2.ioException("PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA", new Object[0]);
}
short readByte = (b & 8) != 0 ? (short) (this.source.readByte() & 255) : (short) 0;
handler.data(z, i2, this.source, lengthWithoutPadding(i, b, readByte));
this.source.skip(readByte);
}
public final void readPriority(Handler handler, int i, byte b, int i2) {
if (i != 5) {
throw Http2.ioException("TYPE_PRIORITY length: %d != 5", Integer.valueOf(i));
}
if (i2 == 0) {
throw Http2.ioException("TYPE_PRIORITY streamId == 0", new Object[0]);
}
readPriority(handler, i2);
}
public final void readPriority(Handler handler, int i) {
int readInt = this.source.readInt();
handler.priority(i, readInt & Integer.MAX_VALUE, (this.source.readByte() & 255) + 1, (Integer.MIN_VALUE & readInt) != 0);
}
public final void readRstStream(Handler handler, int i, byte b, int i2) {
if (i != 4) {
throw Http2.ioException("TYPE_RST_STREAM length: %d != 4", Integer.valueOf(i));
}
if (i2 == 0) {
throw Http2.ioException("TYPE_RST_STREAM streamId == 0", new Object[0]);
}
int readInt = this.source.readInt();
ErrorCode fromHttp2 = ErrorCode.fromHttp2(readInt);
if (fromHttp2 == null) {
throw Http2.ioException("TYPE_RST_STREAM unexpected error code: %d", Integer.valueOf(readInt));
}
handler.rstStream(i2, fromHttp2);
}
public final void readSettings(Handler handler, int i, byte b, int i2) {
if (i2 != 0) {
throw Http2.ioException("TYPE_SETTINGS streamId != 0", new Object[0]);
}
if ((b & 1) != 0) {
if (i != 0) {
throw Http2.ioException("FRAME_SIZE_ERROR ack frame should be empty!", new Object[0]);
}
handler.ackSettings();
return;
}
if (i % 6 != 0) {
throw Http2.ioException("TYPE_SETTINGS length %% 6 != 0: %s", Integer.valueOf(i));
}
Settings settings = new Settings();
for (int i3 = 0; i3 < i; i3 += 6) {
int readShort = this.source.readShort() & 65535;
int readInt = this.source.readInt();
if (readShort != 2) {
if (readShort == 3) {
readShort = 4;
} else if (readShort == 4) {
if (readInt < 0) {
throw Http2.ioException("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1", new Object[0]);
}
readShort = 7;
} else if (readShort == 5 && (readInt < 16384 || readInt > 16777215)) {
throw Http2.ioException("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s", Integer.valueOf(readInt));
}
} else if (readInt != 0 && readInt != 1) {
throw Http2.ioException("PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1", new Object[0]);
}
settings.set(readShort, readInt);
}
handler.settings(false, settings);
}
public final void readPushPromise(Handler handler, int i, byte b, int i2) {
if (i2 == 0) {
throw Http2.ioException("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0", new Object[0]);
}
short readByte = (b & 8) != 0 ? (short) (this.source.readByte() & 255) : (short) 0;
handler.pushPromise(i2, this.source.readInt() & Integer.MAX_VALUE, readHeaderBlock(lengthWithoutPadding(i - 4, b, readByte), readByte, b, i2));
}
public final void readPing(Handler handler, int i, byte b, int i2) {
if (i != 8) {
throw Http2.ioException("TYPE_PING length != 8: %s", Integer.valueOf(i));
}
if (i2 != 0) {
throw Http2.ioException("TYPE_PING streamId != 0", new Object[0]);
}
handler.ping((b & 1) != 0, this.source.readInt(), this.source.readInt());
}
public final void readGoAway(Handler handler, int i, byte b, int i2) {
if (i < 8) {
throw Http2.ioException("TYPE_GOAWAY length < 8: %s", Integer.valueOf(i));
}
if (i2 != 0) {
throw Http2.ioException("TYPE_GOAWAY streamId != 0", new Object[0]);
}
int readInt = this.source.readInt();
int readInt2 = this.source.readInt();
int i3 = i - 8;
ErrorCode fromHttp2 = ErrorCode.fromHttp2(readInt2);
if (fromHttp2 == null) {
throw Http2.ioException("TYPE_GOAWAY unexpected error code: %d", Integer.valueOf(readInt2));
}
ByteString byteString = ByteString.EMPTY;
if (i3 > 0) {
byteString = this.source.readByteString(i3);
}
handler.goAway(readInt, fromHttp2, byteString);
}
public final void readWindowUpdate(Handler handler, int i, byte b, int i2) {
if (i != 4) {
throw Http2.ioException("TYPE_WINDOW_UPDATE length !=4: %s", Integer.valueOf(i));
}
long readInt = this.source.readInt() & 2147483647L;
if (readInt == 0) {
throw Http2.ioException("windowSizeIncrement was 0", Long.valueOf(readInt));
}
handler.windowUpdate(i2, readInt);
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() {
this.source.close();
}
public static final class ContinuationSource implements Source {
public byte flags;
public int left;
public int length;
public short padding;
public final BufferedSource source;
public int streamId;
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
}
public ContinuationSource(BufferedSource bufferedSource) {
this.source = bufferedSource;
}
@Override // okio.Source
public long read(Buffer buffer, long j) {
while (true) {
int i = this.left;
if (i == 0) {
this.source.skip(this.padding);
this.padding = (short) 0;
if ((this.flags & 4) != 0) {
return -1L;
}
readContinuationHeader();
} else {
long read = this.source.read(buffer, Math.min(j, i));
if (read == -1) {
return -1L;
}
this.left = (int) (this.left - read);
return read;
}
}
}
@Override // okio.Source
public Timeout timeout() {
return this.source.timeout();
}
public final void readContinuationHeader() {
int i = this.streamId;
int readMedium = Http2Reader.readMedium(this.source);
this.left = readMedium;
this.length = readMedium;
byte readByte = (byte) (this.source.readByte() & 255);
this.flags = (byte) (this.source.readByte() & 255);
Logger logger = Http2Reader.logger;
if (logger.isLoggable(Level.FINE)) {
logger.fine(Http2.frameLog(true, this.streamId, this.length, readByte, this.flags));
}
int readInt = this.source.readInt() & Integer.MAX_VALUE;
this.streamId = readInt;
if (readByte != 9) {
throw Http2.ioException("%s != TYPE_CONTINUATION", Byte.valueOf(readByte));
}
if (readInt != i) {
throw Http2.ioException("TYPE_CONTINUATION streamId changed", new Object[0]);
}
}
}
public static int readMedium(BufferedSource bufferedSource) {
return (bufferedSource.readByte() & 255) | ((bufferedSource.readByte() & 255) << 16) | ((bufferedSource.readByte() & 255) << 8);
}
public static int lengthWithoutPadding(int i, byte b, short s) {
if ((b & 8) != 0) {
i--;
}
if (s <= i) {
return (short) (i - s);
}
throw Http2.ioException("PROTOCOL_ERROR padding %s > remaining length %s", Short.valueOf(s), Integer.valueOf(i));
}
}

View File

@@ -0,0 +1,640 @@
package okhttp3.internal.http2;
import android.support.v4.media.session.PlaybackStateCompat;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.util.ArrayDeque;
import java.util.Deque;
import okhttp3.Headers;
import okhttp3.internal.Util;
import okio.AsyncTimeout;
import okio.Buffer;
import okio.BufferedSource;
import okio.Sink;
import okio.Source;
import okio.Timeout;
/* loaded from: classes5.dex */
public final class Http2Stream {
public long bytesLeftInWriteWindow;
public final Http2Connection connection;
public ErrorCode errorCode;
public IOException errorException;
public boolean hasResponseHeaders;
public final Deque headersQueue;
public final int id;
public final StreamTimeout readTimeout;
public final FramingSink sink;
public final FramingSource source;
public long unacknowledgedBytesRead = 0;
public final StreamTimeout writeTimeout;
public int getId() {
return this.id;
}
public Source getSource() {
return this.source;
}
public Timeout readTimeout() {
return this.readTimeout;
}
public Timeout writeTimeout() {
return this.writeTimeout;
}
public Http2Stream(int i, Http2Connection http2Connection, boolean z, boolean z2, Headers headers) {
ArrayDeque arrayDeque = new ArrayDeque();
this.headersQueue = arrayDeque;
this.readTimeout = new StreamTimeout();
this.writeTimeout = new StreamTimeout();
if (http2Connection == null) {
throw new NullPointerException("connection == null");
}
this.id = i;
this.connection = http2Connection;
this.bytesLeftInWriteWindow = http2Connection.peerSettings.getInitialWindowSize();
FramingSource framingSource = new FramingSource(http2Connection.okHttpSettings.getInitialWindowSize());
this.source = framingSource;
FramingSink framingSink = new FramingSink();
this.sink = framingSink;
framingSource.finished = z2;
framingSink.finished = z;
if (headers != null) {
arrayDeque.add(headers);
}
if (isLocallyInitiated() && headers != null) {
throw new IllegalStateException("locally-initiated streams shouldn't have headers yet");
}
if (!isLocallyInitiated() && headers == null) {
throw new IllegalStateException("remotely-initiated streams should have headers");
}
}
public synchronized boolean isOpen() {
try {
if (this.errorCode != null) {
return false;
}
FramingSource framingSource = this.source;
if (!framingSource.finished) {
if (framingSource.closed) {
}
return true;
}
FramingSink framingSink = this.sink;
if (framingSink.finished || framingSink.closed) {
if (this.hasResponseHeaders) {
return false;
}
}
return true;
} catch (Throwable th) {
throw th;
}
}
public boolean isLocallyInitiated() {
return this.connection.client == ((this.id & 1) == 1);
}
public synchronized Headers takeHeaders() {
this.readTimeout.enter();
while (this.headersQueue.isEmpty() && this.errorCode == null) {
try {
waitForIo();
} catch (Throwable th) {
this.readTimeout.exitAndThrowIfTimedOut();
throw th;
}
}
this.readTimeout.exitAndThrowIfTimedOut();
if (this.headersQueue.isEmpty()) {
IOException iOException = this.errorException;
if (iOException != null) {
throw iOException;
}
throw new StreamResetException(this.errorCode);
}
return (Headers) this.headersQueue.removeFirst();
}
public Sink getSink() {
synchronized (this) {
try {
if (!this.hasResponseHeaders && !isLocallyInitiated()) {
throw new IllegalStateException("reply before requesting the sink");
}
} catch (Throwable th) {
throw th;
}
}
return this.sink;
}
public void close(ErrorCode errorCode, IOException iOException) {
if (closeInternal(errorCode, iOException)) {
this.connection.writeSynReset(this.id, errorCode);
}
}
public void closeLater(ErrorCode errorCode) {
if (closeInternal(errorCode, null)) {
this.connection.writeSynResetLater(this.id, errorCode);
}
}
public final boolean closeInternal(ErrorCode errorCode, IOException iOException) {
synchronized (this) {
try {
if (this.errorCode != null) {
return false;
}
if (this.source.finished && this.sink.finished) {
return false;
}
this.errorCode = errorCode;
this.errorException = iOException;
notifyAll();
this.connection.removeStream(this.id);
return true;
} catch (Throwable th) {
throw th;
}
}
}
public void receiveData(BufferedSource bufferedSource, int i) {
this.source.receive(bufferedSource, i);
}
/* JADX WARN: Removed duplicated region for block: B:9:0x001a A[Catch: all -> 0x000f, TryCatch #0 {all -> 0x000f, blocks: (B:3:0x0001, B:7:0x0009, B:9:0x001a, B:10:0x001e, B:11:0x0025, B:18:0x0011), top: B:2:0x0001 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void receiveHeaders(okhttp3.Headers r3, boolean r4) {
/*
r2 = this;
monitor-enter(r2)
boolean r0 = r2.hasResponseHeaders // Catch: java.lang.Throwable -> Lf
r1 = 1
if (r0 == 0) goto L11
if (r4 != 0) goto L9
goto L11
L9:
okhttp3.internal.http2.Http2Stream$FramingSource r0 = r2.source // Catch: java.lang.Throwable -> Lf
okhttp3.internal.http2.Http2Stream.FramingSource.access$202(r0, r3) // Catch: java.lang.Throwable -> Lf
goto L18
Lf:
r3 = move-exception
goto L30
L11:
r2.hasResponseHeaders = r1 // Catch: java.lang.Throwable -> Lf
java.util.Deque r0 = r2.headersQueue // Catch: java.lang.Throwable -> Lf
r0.add(r3) // Catch: java.lang.Throwable -> Lf
L18:
if (r4 == 0) goto L1e
okhttp3.internal.http2.Http2Stream$FramingSource r3 = r2.source // Catch: java.lang.Throwable -> Lf
r3.finished = r1 // Catch: java.lang.Throwable -> Lf
L1e:
boolean r3 = r2.isOpen() // Catch: java.lang.Throwable -> Lf
r2.notifyAll() // Catch: java.lang.Throwable -> Lf
monitor-exit(r2) // Catch: java.lang.Throwable -> Lf
if (r3 != 0) goto L2f
okhttp3.internal.http2.Http2Connection r3 = r2.connection
int r4 = r2.id
r3.removeStream(r4)
L2f:
return
L30:
monitor-exit(r2) // Catch: java.lang.Throwable -> Lf
throw r3
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.http2.Http2Stream.receiveHeaders(okhttp3.Headers, boolean):void");
}
public synchronized void receiveRstStream(ErrorCode errorCode) {
if (this.errorCode == null) {
this.errorCode = errorCode;
notifyAll();
}
}
public final class FramingSource implements Source {
public boolean closed;
public boolean finished;
public final long maxByteCount;
public Headers trailers;
public final Buffer receiveBuffer = new Buffer();
public final Buffer readBuffer = new Buffer();
public FramingSource(long j) {
this.maxByteCount = j;
}
/* JADX WARN: Code restructure failed: missing block: B:25:0x0085, code lost:
r12 = -1;
*/
/* JADX WARN: Removed duplicated region for block: B:30:0x0092 */
/* JADX WARN: Removed duplicated region for block: B:33:0x0096 */
@Override // okio.Source
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public long read(okio.Buffer r12, long r13) {
/*
r11 = this;
r0 = 0
int r2 = (r13 > r0 ? 1 : (r13 == r0 ? 0 : -1))
if (r2 < 0) goto Lac
L6:
okhttp3.internal.http2.Http2Stream r2 = okhttp3.internal.http2.Http2Stream.this
monitor-enter(r2)
okhttp3.internal.http2.Http2Stream r3 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L83
okhttp3.internal.http2.Http2Stream$StreamTimeout r3 = r3.readTimeout // Catch: java.lang.Throwable -> L83
r3.enter() // Catch: java.lang.Throwable -> L83
okhttp3.internal.http2.Http2Stream r3 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.ErrorCode r4 = r3.errorCode // Catch: java.lang.Throwable -> L25
if (r4 == 0) goto L28
java.io.IOException r3 = r3.errorException // Catch: java.lang.Throwable -> L25
if (r3 == 0) goto L1b
goto L29
L1b:
okhttp3.internal.http2.StreamResetException r3 = new okhttp3.internal.http2.StreamResetException // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.Http2Stream r4 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.ErrorCode r4 = r4.errorCode // Catch: java.lang.Throwable -> L25
r3.<init>(r4) // Catch: java.lang.Throwable -> L25
goto L29
L25:
r12 = move-exception
goto La2
L28:
r3 = 0
L29:
boolean r4 = r11.closed // Catch: java.lang.Throwable -> L25
if (r4 != 0) goto L9a
okio.Buffer r4 = r11.readBuffer // Catch: java.lang.Throwable -> L25
long r4 = r4.size() // Catch: java.lang.Throwable -> L25
int r4 = (r4 > r0 ? 1 : (r4 == r0 ? 0 : -1))
r5 = -1
if (r4 <= 0) goto L6f
okio.Buffer r4 = r11.readBuffer // Catch: java.lang.Throwable -> L25
long r7 = r4.size() // Catch: java.lang.Throwable -> L25
long r13 = java.lang.Math.min(r13, r7) // Catch: java.lang.Throwable -> L25
long r12 = r4.read(r12, r13) // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.Http2Stream r14 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L25
long r7 = r14.unacknowledgedBytesRead // Catch: java.lang.Throwable -> L25
long r7 = r7 + r12
r14.unacknowledgedBytesRead = r7 // Catch: java.lang.Throwable -> L25
if (r3 != 0) goto L86
okhttp3.internal.http2.Http2Connection r14 = r14.connection // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.Settings r14 = r14.okHttpSettings // Catch: java.lang.Throwable -> L25
int r14 = r14.getInitialWindowSize() // Catch: java.lang.Throwable -> L25
int r14 = r14 / 2
long r9 = (long) r14 // Catch: java.lang.Throwable -> L25
int r14 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1))
if (r14 < 0) goto L86
okhttp3.internal.http2.Http2Stream r14 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.Http2Connection r4 = r14.connection // Catch: java.lang.Throwable -> L25
int r7 = r14.id // Catch: java.lang.Throwable -> L25
long r8 = r14.unacknowledgedBytesRead // Catch: java.lang.Throwable -> L25
r4.writeWindowUpdateLater(r7, r8) // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.Http2Stream r14 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L25
r14.unacknowledgedBytesRead = r0 // Catch: java.lang.Throwable -> L25
goto L86
L6f:
boolean r4 = r11.finished // Catch: java.lang.Throwable -> L25
if (r4 != 0) goto L85
if (r3 != 0) goto L85
okhttp3.internal.http2.Http2Stream r3 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L25
r3.waitForIo() // Catch: java.lang.Throwable -> L25
okhttp3.internal.http2.Http2Stream r3 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L83
okhttp3.internal.http2.Http2Stream$StreamTimeout r3 = r3.readTimeout // Catch: java.lang.Throwable -> L83
r3.exitAndThrowIfTimedOut() // Catch: java.lang.Throwable -> L83
monitor-exit(r2) // Catch: java.lang.Throwable -> L83
goto L6
L83:
r12 = move-exception
goto Laa
L85:
r12 = r5
L86:
okhttp3.internal.http2.Http2Stream r14 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L83
okhttp3.internal.http2.Http2Stream$StreamTimeout r14 = r14.readTimeout // Catch: java.lang.Throwable -> L83
r14.exitAndThrowIfTimedOut() // Catch: java.lang.Throwable -> L83
monitor-exit(r2) // Catch: java.lang.Throwable -> L83
int r14 = (r12 > r5 ? 1 : (r12 == r5 ? 0 : -1))
if (r14 == 0) goto L96
r11.updateConnectionFlowControl(r12)
return r12
L96:
if (r3 != 0) goto L99
return r5
L99:
throw r3
L9a:
java.io.IOException r12 = new java.io.IOException // Catch: java.lang.Throwable -> L25
java.lang.String r13 = "stream closed"
r12.<init>(r13) // Catch: java.lang.Throwable -> L25
throw r12 // Catch: java.lang.Throwable -> L25
La2:
okhttp3.internal.http2.Http2Stream r13 = okhttp3.internal.http2.Http2Stream.this // Catch: java.lang.Throwable -> L83
okhttp3.internal.http2.Http2Stream$StreamTimeout r13 = r13.readTimeout // Catch: java.lang.Throwable -> L83
r13.exitAndThrowIfTimedOut() // Catch: java.lang.Throwable -> L83
throw r12 // Catch: java.lang.Throwable -> L83
Laa:
monitor-exit(r2) // Catch: java.lang.Throwable -> L83
throw r12
Lac:
java.lang.IllegalArgumentException r12 = new java.lang.IllegalArgumentException
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r1 = "byteCount < 0: "
r0.append(r1)
r0.append(r13)
java.lang.String r13 = r0.toString()
r12.<init>(r13)
throw r12
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.http2.Http2Stream.FramingSource.read(okio.Buffer, long):long");
}
public final void updateConnectionFlowControl(long j) {
Http2Stream.this.connection.updateConnectionFlowControl(j);
}
public void receive(BufferedSource bufferedSource, long j) {
boolean z;
boolean z2;
long j2;
while (j > 0) {
synchronized (Http2Stream.this) {
z = this.finished;
z2 = this.readBuffer.size() + j > this.maxByteCount;
}
if (z2) {
bufferedSource.skip(j);
Http2Stream.this.closeLater(ErrorCode.FLOW_CONTROL_ERROR);
return;
}
if (z) {
bufferedSource.skip(j);
return;
}
long read = bufferedSource.read(this.receiveBuffer, j);
if (read == -1) {
throw new EOFException();
}
j -= read;
synchronized (Http2Stream.this) {
try {
if (this.closed) {
j2 = this.receiveBuffer.size();
this.receiveBuffer.clear();
} else {
boolean z3 = this.readBuffer.size() == 0;
this.readBuffer.writeAll(this.receiveBuffer);
if (z3) {
Http2Stream.this.notifyAll();
}
j2 = 0;
}
} finally {
}
}
if (j2 > 0) {
updateConnectionFlowControl(j2);
}
}
}
@Override // okio.Source
public Timeout timeout() {
return Http2Stream.this.readTimeout;
}
@Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() {
long size;
synchronized (Http2Stream.this) {
this.closed = true;
size = this.readBuffer.size();
this.readBuffer.clear();
Http2Stream.this.notifyAll();
}
if (size > 0) {
updateConnectionFlowControl(size);
}
Http2Stream.this.cancelStreamIfNecessary();
}
}
public void cancelStreamIfNecessary() {
boolean z;
boolean isOpen;
synchronized (this) {
try {
FramingSource framingSource = this.source;
if (!framingSource.finished && framingSource.closed) {
FramingSink framingSink = this.sink;
if (!framingSink.finished) {
if (framingSink.closed) {
}
}
z = true;
isOpen = isOpen();
}
z = false;
isOpen = isOpen();
} catch (Throwable th) {
throw th;
}
}
if (z) {
close(ErrorCode.CANCEL, null);
} else {
if (isOpen) {
return;
}
this.connection.removeStream(this.id);
}
}
public final class FramingSink implements Sink {
public boolean closed;
public boolean finished;
public final Buffer sendBuffer = new Buffer();
public Headers trailers;
public FramingSink() {
}
@Override // okio.Sink
public void write(Buffer buffer, long j) {
this.sendBuffer.write(buffer, j);
while (this.sendBuffer.size() >= PlaybackStateCompat.ACTION_PREPARE) {
emitFrame(false);
}
}
public final void emitFrame(boolean z) {
Http2Stream http2Stream;
long min;
Http2Stream http2Stream2;
boolean z2;
synchronized (Http2Stream.this) {
Http2Stream.this.writeTimeout.enter();
while (true) {
try {
http2Stream = Http2Stream.this;
if (http2Stream.bytesLeftInWriteWindow > 0 || this.finished || this.closed || http2Stream.errorCode != null) {
break;
} else {
http2Stream.waitForIo();
}
} finally {
Http2Stream.this.writeTimeout.exitAndThrowIfTimedOut();
}
}
http2Stream.writeTimeout.exitAndThrowIfTimedOut();
Http2Stream.this.checkOutNotClosed();
min = Math.min(Http2Stream.this.bytesLeftInWriteWindow, this.sendBuffer.size());
http2Stream2 = Http2Stream.this;
http2Stream2.bytesLeftInWriteWindow -= min;
}
http2Stream2.writeTimeout.enter();
if (z) {
try {
if (min == this.sendBuffer.size()) {
z2 = true;
boolean z3 = z2;
Http2Stream http2Stream3 = Http2Stream.this;
http2Stream3.connection.writeData(http2Stream3.id, z3, this.sendBuffer, min);
}
} catch (Throwable th) {
throw th;
}
}
z2 = false;
boolean z32 = z2;
Http2Stream http2Stream32 = Http2Stream.this;
http2Stream32.connection.writeData(http2Stream32.id, z32, this.sendBuffer, min);
}
@Override // okio.Sink, java.io.Flushable
public void flush() {
synchronized (Http2Stream.this) {
Http2Stream.this.checkOutNotClosed();
}
while (this.sendBuffer.size() > 0) {
emitFrame(false);
Http2Stream.this.connection.flush();
}
}
@Override // okio.Sink
public Timeout timeout() {
return Http2Stream.this.writeTimeout;
}
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() {
synchronized (Http2Stream.this) {
try {
if (this.closed) {
return;
}
if (!Http2Stream.this.sink.finished) {
boolean z = this.sendBuffer.size() > 0;
if (this.trailers != null) {
while (this.sendBuffer.size() > 0) {
emitFrame(false);
}
Http2Stream http2Stream = Http2Stream.this;
http2Stream.connection.writeHeaders(http2Stream.id, true, Util.toHeaderBlock(this.trailers));
} else if (z) {
while (this.sendBuffer.size() > 0) {
emitFrame(true);
}
} else {
Http2Stream http2Stream2 = Http2Stream.this;
http2Stream2.connection.writeData(http2Stream2.id, true, null, 0L);
}
}
synchronized (Http2Stream.this) {
this.closed = true;
}
Http2Stream.this.connection.flush();
Http2Stream.this.cancelStreamIfNecessary();
} catch (Throwable th) {
throw th;
}
}
}
}
public void addBytesToWriteWindow(long j) {
this.bytesLeftInWriteWindow += j;
if (j > 0) {
notifyAll();
}
}
public void checkOutNotClosed() {
FramingSink framingSink = this.sink;
if (framingSink.closed) {
throw new IOException("stream closed");
}
if (framingSink.finished) {
throw new IOException("stream finished");
}
if (this.errorCode != null) {
IOException iOException = this.errorException;
if (iOException == null) {
throw new StreamResetException(this.errorCode);
}
}
}
public void waitForIo() {
try {
wait();
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
throw new InterruptedIOException();
}
}
public class StreamTimeout extends AsyncTimeout {
public StreamTimeout() {
}
@Override // okio.AsyncTimeout
public void timedOut() {
Http2Stream.this.closeLater(ErrorCode.CANCEL);
Http2Stream.this.connection.sendDegradedPingLater();
}
@Override // okio.AsyncTimeout
public IOException newTimeoutException(IOException iOException) {
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
if (iOException != null) {
socketTimeoutException.initCause(iOException);
}
return socketTimeoutException;
}
public void exitAndThrowIfTimedOut() {
if (exit()) {
throw newTimeoutException(null);
}
}
}
}

View File

@@ -0,0 +1,240 @@
package okhttp3.internal.http2;
import csdk.gluads.Consts;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import okhttp3.internal.Util;
import okhttp3.internal.http2.Hpack;
import okio.Buffer;
import okio.BufferedSink;
/* loaded from: classes5.dex */
public final class Http2Writer implements Closeable {
public static final Logger logger = Logger.getLogger(Http2.class.getName());
public final boolean client;
public boolean closed;
public final Buffer hpackBuffer;
public final Hpack.Writer hpackWriter;
public int maxFrameSize;
public final BufferedSink sink;
public int maxDataLength() {
return this.maxFrameSize;
}
public Http2Writer(BufferedSink bufferedSink, boolean z) {
this.sink = bufferedSink;
this.client = z;
Buffer buffer = new Buffer();
this.hpackBuffer = buffer;
this.hpackWriter = new Hpack.Writer(buffer);
this.maxFrameSize = 16384;
}
public synchronized void connectionPreface() {
try {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (this.client) {
Logger logger2 = logger;
if (logger2.isLoggable(Level.FINE)) {
logger2.fine(Util.format(">> CONNECTION %s", Http2.CONNECTION_PREFACE.hex()));
}
this.sink.write(Http2.CONNECTION_PREFACE.toByteArray());
this.sink.flush();
}
} catch (Throwable th) {
throw th;
}
}
public synchronized void applyAndAckSettings(Settings settings) {
try {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.maxFrameSize = settings.getMaxFrameSize(this.maxFrameSize);
if (settings.getHeaderTableSize() != -1) {
this.hpackWriter.setHeaderTableSizeSetting(settings.getHeaderTableSize());
}
frameHeader(0, 0, (byte) 4, (byte) 1);
this.sink.flush();
} catch (Throwable th) {
throw th;
}
}
public synchronized void pushPromise(int i, int i2, List list) {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.hpackWriter.writeHeaders(list);
long size = this.hpackBuffer.size();
int min = (int) Math.min(this.maxFrameSize - 4, size);
long j = min;
frameHeader(i, min + 4, (byte) 5, size == j ? (byte) 4 : (byte) 0);
this.sink.writeInt(i2 & Integer.MAX_VALUE);
this.sink.write(this.hpackBuffer, j);
if (size > j) {
writeContinuationFrames(i, size - j);
}
}
public synchronized void flush() {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.sink.flush();
}
public synchronized void rstStream(int i, ErrorCode errorCode) {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (errorCode.httpCode == -1) {
throw new IllegalArgumentException();
}
frameHeader(i, 4, (byte) 3, (byte) 0);
this.sink.writeInt(errorCode.httpCode);
this.sink.flush();
}
public synchronized void data(boolean z, int i, Buffer buffer, int i2) {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
dataFrame(i, z ? (byte) 1 : (byte) 0, buffer, i2);
}
public void dataFrame(int i, byte b, Buffer buffer, int i2) {
frameHeader(i, i2, (byte) 0, b);
if (i2 > 0) {
this.sink.write(buffer, i2);
}
}
public synchronized void settings(Settings settings) {
try {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
int i = 0;
frameHeader(0, settings.size() * 6, (byte) 4, (byte) 0);
while (i < 10) {
if (settings.isSet(i)) {
this.sink.writeShort(i == 4 ? 3 : i == 7 ? 4 : i);
this.sink.writeInt(settings.get(i));
}
i++;
}
this.sink.flush();
} catch (Throwable th) {
throw th;
}
}
public synchronized void ping(boolean z, int i, int i2) {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
frameHeader(0, 8, (byte) 6, z ? (byte) 1 : (byte) 0);
this.sink.writeInt(i);
this.sink.writeInt(i2);
this.sink.flush();
}
public synchronized void goAway(int i, ErrorCode errorCode, byte[] bArr) {
try {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (errorCode.httpCode == -1) {
throw Http2.illegalArgument("errorCode.httpCode == -1", new Object[0]);
}
frameHeader(0, bArr.length + 8, (byte) 7, (byte) 0);
this.sink.writeInt(i);
this.sink.writeInt(errorCode.httpCode);
if (bArr.length > 0) {
this.sink.write(bArr);
}
this.sink.flush();
} catch (Throwable th) {
throw th;
}
}
public synchronized void windowUpdate(int i, long j) {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
if (j == 0 || j > 2147483647L) {
throw Http2.illegalArgument("windowSizeIncrement == 0 || windowSizeIncrement > 0x7fffffffL: %s", Long.valueOf(j));
}
frameHeader(i, 4, (byte) 8, (byte) 0);
this.sink.writeInt((int) j);
this.sink.flush();
}
public void frameHeader(int i, int i2, byte b, byte b2) {
Logger logger2 = logger;
if (logger2.isLoggable(Level.FINE)) {
logger2.fine(Http2.frameLog(false, i, i2, b, b2));
}
int i3 = this.maxFrameSize;
if (i2 > i3) {
throw Http2.illegalArgument("FRAME_SIZE_ERROR length > %d: %d", Integer.valueOf(i3), Integer.valueOf(i2));
}
if ((Integer.MIN_VALUE & i) != 0) {
throw Http2.illegalArgument("reserved bit set: %s", Integer.valueOf(i));
}
writeMedium(this.sink, i2);
this.sink.writeByte(b & 255);
this.sink.writeByte(b2 & 255);
this.sink.writeInt(i & Integer.MAX_VALUE);
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public synchronized void close() {
this.closed = true;
this.sink.close();
}
public static void writeMedium(BufferedSink bufferedSink, int i) {
bufferedSink.writeByte((i >>> 16) & 255);
bufferedSink.writeByte((i >>> 8) & 255);
bufferedSink.writeByte(i & 255);
}
public final void writeContinuationFrames(int i, long j) {
while (j > 0) {
int min = (int) Math.min(this.maxFrameSize, j);
long j2 = min;
j -= j2;
frameHeader(i, min, (byte) 9, j == 0 ? (byte) 4 : (byte) 0);
this.sink.write(this.hpackBuffer, j2);
}
}
public synchronized void headers(boolean z, int i, List list) {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.hpackWriter.writeHeaders(list);
long size = this.hpackBuffer.size();
int min = (int) Math.min(this.maxFrameSize, size);
long j = min;
byte b = size == j ? (byte) 4 : (byte) 0;
if (z) {
b = (byte) (b | 1);
}
frameHeader(i, min, (byte) 1, b);
this.sink.write(this.hpackBuffer, j);
if (size > j) {
writeContinuationFrames(i, size - j);
}
}
}

View File

@@ -0,0 +1,136 @@
package okhttp3.internal.http2;
import androidx.core.view.PointerIconCompat;
import com.applovin.exoplayer2.common.base.Ascii;
import com.vungle.ads.internal.signals.SignalKey;
import java.io.ByteArrayOutputStream;
import okio.BufferedSink;
import okio.ByteString;
/* loaded from: classes5.dex */
public class Huffman {
public static final int[] CODES = {8184, 8388568, 268435426, 268435427, 268435428, 268435429, 268435430, 268435431, 268435432, 16777194, 1073741820, 268435433, 268435434, 1073741821, 268435435, 268435436, 268435437, 268435438, 268435439, 268435440, 268435441, 268435442, 1073741822, 268435443, 268435444, 268435445, 268435446, 268435447, 268435448, 268435449, 268435450, 268435451, 20, 1016, PointerIconCompat.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW, 4090, 8185, 21, 248, 2042, 1018, 1019, 249, 2043, 250, 22, 23, 24, 0, 1, 2, 25, 26, 27, 28, 29, 30, 31, 92, 251, 32764, 32, 4091, 1020, 8186, 33, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, SignalKey.EVENT_ID, 108, 109, 110, 111, 112, 113, 114, 252, 115, 253, 8187, 524272, 8188, 16380, 34, 32765, 3, 35, 4, 36, 5, 37, 38, 39, 6, 116, 117, 40, 41, 42, 7, 43, 118, 44, 8, 9, 45, 119, 120, 121, 122, 123, 32766, 2044, 16381, 8189, 268435452, 1048550, 4194258, 1048551, 1048552, 4194259, 4194260, 4194261, 8388569, 4194262, 8388570, 8388571, 8388572, 8388573, 8388574, 16777195, 8388575, 16777196, 16777197, 4194263, 8388576, 16777198, 8388577, 8388578, 8388579, 8388580, 2097116, 4194264, 8388581, 4194265, 8388582, 8388583, 16777199, 4194266, 2097117, 1048553, 4194267, 4194268, 8388584, 8388585, 2097118, 8388586, 4194269, 4194270, 16777200, 2097119, 4194271, 8388587, 8388588, 2097120, 2097121, 4194272, 2097122, 8388589, 4194273, 8388590, 8388591, 1048554, 4194274, 4194275, 4194276, 8388592, 4194277, 4194278, 8388593, 67108832, 67108833, 1048555, 524273, 4194279, 8388594, 4194280, 33554412, 67108834, 67108835, 67108836, 134217694, 134217695, 67108837, 16777201, 33554413, 524274, 2097123, 67108838, 134217696, 134217697, 67108839, 134217698, 16777202, 2097124, 2097125, 67108840, 67108841, 268435453, 134217699, 134217700, 134217701, 1048556, 16777203, 1048557, 2097126, 4194281, 2097127, 2097128, 8388595, 4194282, 4194283, 33554414, 33554415, 16777204, 16777205, 67108842, 8388596, 67108843, 134217702, 67108844, 67108845, 134217703, 134217704, 134217705, 134217706, 134217707, 268435454, 134217708, 134217709, 134217710, 134217711, 134217712, 67108846};
public static final byte[] CODE_LENGTHS = {Ascii.CR, Ascii.ETB, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.CAN, Ascii.RS, Ascii.FS, Ascii.FS, Ascii.RS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.RS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, Ascii.FS, 6, 10, 10, Ascii.FF, Ascii.CR, 6, 8, Ascii.VT, 10, 10, 8, Ascii.VT, 8, 6, 6, 6, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 8, Ascii.SI, 6, Ascii.FF, 10, Ascii.CR, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, Ascii.CR, 19, Ascii.CR, Ascii.SO, 6, Ascii.SI, 5, 6, 5, 6, 5, 6, 6, 6, 5, 7, 7, 6, 6, 6, 5, 6, 7, 6, 5, 5, 6, 7, 7, 7, 7, 7, Ascii.SI, Ascii.VT, Ascii.SO, Ascii.CR, Ascii.FS, Ascii.DC4, Ascii.SYN, Ascii.DC4, Ascii.DC4, Ascii.SYN, Ascii.SYN, Ascii.SYN, Ascii.ETB, Ascii.SYN, Ascii.ETB, Ascii.ETB, Ascii.ETB, Ascii.ETB, Ascii.ETB, Ascii.CAN, Ascii.ETB, Ascii.CAN, Ascii.CAN, Ascii.SYN, Ascii.ETB, Ascii.CAN, Ascii.ETB, Ascii.ETB, Ascii.ETB, Ascii.ETB, Ascii.NAK, Ascii.SYN, Ascii.ETB, Ascii.SYN, Ascii.ETB, Ascii.ETB, Ascii.CAN, Ascii.SYN, Ascii.NAK, Ascii.DC4, Ascii.SYN, Ascii.SYN, Ascii.ETB, Ascii.ETB, Ascii.NAK, Ascii.ETB, Ascii.SYN, Ascii.SYN, Ascii.CAN, Ascii.NAK, Ascii.SYN, Ascii.ETB, Ascii.ETB, Ascii.NAK, Ascii.NAK, Ascii.SYN, Ascii.NAK, Ascii.ETB, Ascii.SYN, Ascii.ETB, Ascii.ETB, Ascii.DC4, Ascii.SYN, Ascii.SYN, Ascii.SYN, Ascii.ETB, Ascii.SYN, Ascii.SYN, Ascii.ETB, Ascii.SUB, Ascii.SUB, Ascii.DC4, 19, Ascii.SYN, Ascii.ETB, Ascii.SYN, Ascii.EM, Ascii.SUB, Ascii.SUB, Ascii.SUB, Ascii.ESC, Ascii.ESC, Ascii.SUB, Ascii.CAN, Ascii.EM, 19, Ascii.NAK, Ascii.SUB, Ascii.ESC, Ascii.ESC, Ascii.SUB, Ascii.ESC, Ascii.CAN, Ascii.NAK, Ascii.NAK, Ascii.SUB, Ascii.SUB, Ascii.FS, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.DC4, Ascii.CAN, Ascii.DC4, Ascii.NAK, Ascii.SYN, Ascii.NAK, Ascii.NAK, Ascii.ETB, Ascii.SYN, Ascii.SYN, Ascii.EM, Ascii.EM, Ascii.CAN, Ascii.CAN, Ascii.SUB, Ascii.ETB, Ascii.SUB, Ascii.ESC, Ascii.SUB, Ascii.SUB, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.FS, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.ESC, Ascii.SUB};
public static final Huffman INSTANCE = new Huffman();
public final Node root = new Node();
public static Huffman get() {
return INSTANCE;
}
public Huffman() {
buildTree();
}
public void encode(ByteString byteString, BufferedSink bufferedSink) {
long j = 0;
int i = 0;
for (int i2 = 0; i2 < byteString.size(); i2++) {
int i3 = byteString.getByte(i2) & 255;
int i4 = CODES[i3];
byte b = CODE_LENGTHS[i3];
j = (j << b) | i4;
i += b;
while (i >= 8) {
i -= 8;
bufferedSink.writeByte((int) (j >> i));
}
}
if (i > 0) {
bufferedSink.writeByte((int) ((j << (8 - i)) | (255 >>> i)));
}
}
public int encodedLength(ByteString byteString) {
long j = 0;
for (int i = 0; i < byteString.size(); i++) {
j += CODE_LENGTHS[byteString.getByte(i) & 255];
}
return (int) ((j + 7) >> 3);
}
public byte[] decode(byte[] bArr) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Node node = this.root;
int i = 0;
int i2 = 0;
for (byte b : bArr) {
i = (i << 8) | (b & 255);
i2 += 8;
while (i2 >= 8) {
node = node.children[(i >>> (i2 - 8)) & 255];
if (node.children == null) {
byteArrayOutputStream.write(node.symbol);
i2 -= node.terminalBits;
node = this.root;
} else {
i2 -= 8;
}
}
}
while (i2 > 0) {
Node node2 = node.children[(i << (8 - i2)) & 255];
if (node2.children != null || node2.terminalBits > i2) {
break;
}
byteArrayOutputStream.write(node2.symbol);
i2 -= node2.terminalBits;
node = this.root;
}
return byteArrayOutputStream.toByteArray();
}
public final void buildTree() {
int i = 0;
while (true) {
byte[] bArr = CODE_LENGTHS;
if (i >= bArr.length) {
return;
}
addCode(i, CODES[i], bArr[i]);
i++;
}
}
public final void addCode(int i, int i2, byte b) {
Node node = new Node(i, b);
Node node2 = this.root;
while (b > 8) {
b = (byte) (b - 8);
int i3 = (i2 >>> b) & 255;
Node[] nodeArr = node2.children;
if (nodeArr == null) {
throw new IllegalStateException("invalid dictionary: prefix not unique");
}
if (nodeArr[i3] == null) {
nodeArr[i3] = new Node();
}
node2 = node2.children[i3];
}
int i4 = 8 - b;
int i5 = (i2 << i4) & 255;
int i6 = 1 << i4;
for (int i7 = i5; i7 < i5 + i6; i7++) {
node2.children[i7] = node;
}
}
public static final class Node {
public final Node[] children;
public final int symbol;
public final int terminalBits;
public Node() {
this.children = new Node[256];
this.symbol = 0;
this.terminalBits = 0;
}
public Node(int i, int i2) {
this.children = null;
this.symbol = i;
int i3 = i2 & 7;
this.terminalBits = i3 == 0 ? 8 : i3;
}
}
}

View File

@@ -0,0 +1,37 @@
package okhttp3.internal.http2;
import java.util.List;
import okio.BufferedSource;
/* loaded from: classes5.dex */
public interface PushObserver {
public static final PushObserver CANCEL = new PushObserver() { // from class: okhttp3.internal.http2.PushObserver.1
@Override // okhttp3.internal.http2.PushObserver
public boolean onHeaders(int i, List list, boolean z) {
return true;
}
@Override // okhttp3.internal.http2.PushObserver
public boolean onRequest(int i, List list) {
return true;
}
@Override // okhttp3.internal.http2.PushObserver
public void onReset(int i, ErrorCode errorCode) {
}
@Override // okhttp3.internal.http2.PushObserver
public boolean onData(int i, BufferedSource bufferedSource, int i2, boolean z) {
bufferedSource.skip(i2);
return true;
}
};
boolean onData(int i, BufferedSource bufferedSource, int i2, boolean z);
boolean onHeaders(int i, List list, boolean z);
boolean onRequest(int i, List list);
void onReset(int i, ErrorCode errorCode);
}

View File

@@ -0,0 +1,65 @@
package okhttp3.internal.http2;
import androidx.core.internal.view.SupportMenu;
import java.util.Arrays;
/* loaded from: classes5.dex */
public final class Settings {
public int set;
public final int[] values = new int[10];
public boolean isSet(int i) {
return ((1 << i) & this.set) != 0;
}
public void clear() {
this.set = 0;
Arrays.fill(this.values, 0);
}
public Settings set(int i, int i2) {
if (i >= 0) {
int[] iArr = this.values;
if (i < iArr.length) {
this.set = (1 << i) | this.set;
iArr[i] = i2;
}
}
return this;
}
public int get(int i) {
return this.values[i];
}
public int size() {
return Integer.bitCount(this.set);
}
public int getHeaderTableSize() {
if ((this.set & 2) != 0) {
return this.values[1];
}
return -1;
}
public int getMaxConcurrentStreams(int i) {
return (this.set & 16) != 0 ? this.values[4] : i;
}
public int getMaxFrameSize(int i) {
return (this.set & 32) != 0 ? this.values[5] : i;
}
public int getInitialWindowSize() {
return (this.set & 128) != 0 ? this.values[7] : SupportMenu.USER_MASK;
}
public void merge(Settings settings) {
for (int i = 0; i < 10; i++) {
if (settings.isSet(i)) {
set(i, settings.get(i));
}
}
}
}

View File

@@ -0,0 +1,13 @@
package okhttp3.internal.http2;
import java.io.IOException;
/* loaded from: classes5.dex */
public final class StreamResetException extends IOException {
public final ErrorCode errorCode;
public StreamResetException(ErrorCode errorCode) {
super("stream was reset: " + errorCode);
this.errorCode = errorCode;
}
}

View File

@@ -0,0 +1,97 @@
package okhttp3.internal.io;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import okio.Okio;
import okio.Sink;
import okio.Source;
/* loaded from: classes5.dex */
public interface FileSystem {
public static final FileSystem SYSTEM = new FileSystem() { // from class: okhttp3.internal.io.FileSystem.1
@Override // okhttp3.internal.io.FileSystem
public Source source(File file) {
return Okio.source(file);
}
@Override // okhttp3.internal.io.FileSystem
public Sink sink(File file) {
try {
return Okio.sink(file);
} catch (FileNotFoundException unused) {
file.getParentFile().mkdirs();
return Okio.sink(file);
}
}
@Override // okhttp3.internal.io.FileSystem
public Sink appendingSink(File file) {
try {
return Okio.appendingSink(file);
} catch (FileNotFoundException unused) {
file.getParentFile().mkdirs();
return Okio.appendingSink(file);
}
}
@Override // okhttp3.internal.io.FileSystem
public void delete(File file) {
if (file.delete() || !file.exists()) {
return;
}
throw new IOException("failed to delete " + file);
}
@Override // okhttp3.internal.io.FileSystem
public boolean exists(File file) {
return file.exists();
}
@Override // okhttp3.internal.io.FileSystem
public long size(File file) {
return file.length();
}
@Override // okhttp3.internal.io.FileSystem
public void rename(File file, File file2) {
delete(file2);
if (file.renameTo(file2)) {
return;
}
throw new IOException("failed to rename " + file + " to " + file2);
}
@Override // okhttp3.internal.io.FileSystem
public void deleteContents(File file) {
File[] listFiles = file.listFiles();
if (listFiles == null) {
throw new IOException("not a readable directory: " + file);
}
for (File file2 : listFiles) {
if (file2.isDirectory()) {
deleteContents(file2);
}
if (!file2.delete()) {
throw new IOException("failed to delete " + file2);
}
}
}
};
Sink appendingSink(File file);
void delete(File file);
void deleteContents(File file);
boolean exists(File file);
void rename(File file, File file2);
Sink sink(File file);
long size(File file);
Source source(File file);
}

View File

@@ -0,0 +1,57 @@
package okhttp3.internal.platform;
import android.net.ssl.SSLSockets;
import java.io.IOException;
import java.util.List;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
/* loaded from: classes5.dex */
public class Android10Platform extends AndroidPlatform {
public Android10Platform(Class cls) {
super(cls, null, null, null, null, null);
}
@Override // okhttp3.internal.platform.AndroidPlatform, okhttp3.internal.platform.Platform
public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) {
try {
enableSessionTickets(sSLSocket);
SSLParameters sSLParameters = sSLSocket.getSSLParameters();
sSLParameters.setApplicationProtocols((String[]) Platform.alpnProtocolNames(list).toArray(new String[0]));
sSLSocket.setSSLParameters(sSLParameters);
} catch (IllegalArgumentException e) {
throw new IOException("Android internal error", e);
}
}
public final void enableSessionTickets(SSLSocket sSLSocket) {
boolean isSupportedSocket;
isSupportedSocket = SSLSockets.isSupportedSocket(sSLSocket);
if (isSupportedSocket) {
SSLSockets.setUseSessionTickets(sSLSocket, true);
}
}
@Override // okhttp3.internal.platform.AndroidPlatform, okhttp3.internal.platform.Platform
public String getSelectedProtocol(SSLSocket sSLSocket) {
String applicationProtocol;
applicationProtocol = sSLSocket.getApplicationProtocol();
if (applicationProtocol == null || applicationProtocol.isEmpty()) {
return null;
}
return applicationProtocol;
}
public static Platform buildIfSupported() {
if (!Platform.isAndroid()) {
return null;
}
try {
if (AndroidPlatform.getSdkInt() >= 29) {
return new Android10Platform(Class.forName("com.android.org.conscrypt.SSLParametersImpl"));
}
} catch (ReflectiveOperationException unused) {
}
return null;
}
}

View File

@@ -0,0 +1,349 @@
package okhttp3.internal.platform;
import android.os.Build;
import android.util.Log;
import com.vungle.ads.internal.presenter.MRAIDPresenter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.security.cert.TrustAnchor;
import java.security.cert.X509Certificate;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.X509TrustManager;
import okhttp3.internal.Util;
import okhttp3.internal.tls.CertificateChainCleaner;
import okhttp3.internal.tls.TrustRootIndex;
/* loaded from: classes5.dex */
public class AndroidPlatform extends Platform {
public final CloseGuard closeGuard = CloseGuard.get();
public final Method getAlpnSelectedProtocol;
public final Method setAlpnProtocols;
public final Method setHostname;
public final Method setUseSessionTickets;
public final Class sslParametersClass;
public final Class sslSocketClass;
public static int getSdkInt() {
try {
return Build.VERSION.SDK_INT;
} catch (NoClassDefFoundError unused) {
return 0;
}
}
public AndroidPlatform(Class cls, Class cls2, Method method, Method method2, Method method3, Method method4) {
this.sslParametersClass = cls;
this.sslSocketClass = cls2;
this.setUseSessionTickets = method;
this.setHostname = method2;
this.getAlpnSelectedProtocol = method3;
this.setAlpnProtocols = method4;
}
@Override // okhttp3.internal.platform.Platform
public void connectSocket(Socket socket, InetSocketAddress inetSocketAddress, int i) {
try {
socket.connect(inetSocketAddress, i);
} catch (AssertionError e) {
if (!Util.isAndroidGetsocknameError(e)) {
throw e;
}
throw new IOException(e);
} catch (ClassCastException e2) {
if (Build.VERSION.SDK_INT == 26) {
throw new IOException("Exception in connect", e2);
}
throw e2;
}
}
@Override // okhttp3.internal.platform.Platform
public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) {
if (this.sslSocketClass.isInstance(sSLSocket)) {
if (str != null) {
try {
this.setUseSessionTickets.invoke(sSLSocket, Boolean.TRUE);
this.setHostname.invoke(sSLSocket, str);
} catch (IllegalAccessException e) {
e = e;
throw new AssertionError(e);
} catch (InvocationTargetException e2) {
e = e2;
throw new AssertionError(e);
}
}
this.setAlpnProtocols.invoke(sSLSocket, Platform.concatLengthPrefixed(list));
}
}
@Override // okhttp3.internal.platform.Platform
public String getSelectedProtocol(SSLSocket sSLSocket) {
if (!this.sslSocketClass.isInstance(sSLSocket)) {
return null;
}
try {
byte[] bArr = (byte[]) this.getAlpnSelectedProtocol.invoke(sSLSocket, new Object[0]);
if (bArr != null) {
return new String(bArr, StandardCharsets.UTF_8);
}
return null;
} catch (IllegalAccessException | InvocationTargetException e) {
throw new AssertionError(e);
}
}
@Override // okhttp3.internal.platform.Platform
public void log(int i, String str, Throwable th) {
int min;
int i2 = i != 5 ? 3 : 5;
if (th != null) {
str = str + '\n' + Log.getStackTraceString(th);
}
int length = str.length();
int i3 = 0;
while (i3 < length) {
int indexOf = str.indexOf(10, i3);
if (indexOf == -1) {
indexOf = length;
}
while (true) {
min = Math.min(indexOf, i3 + 4000);
Log.println(i2, "OkHttp", str.substring(i3, min));
if (min >= indexOf) {
break;
} else {
i3 = min;
}
}
i3 = min + 1;
}
}
@Override // okhttp3.internal.platform.Platform
public Object getStackTraceForCloseable(String str) {
return this.closeGuard.createAndOpen(str);
}
@Override // okhttp3.internal.platform.Platform
public void logCloseableLeak(String str, Object obj) {
if (this.closeGuard.warnIfOpen(obj)) {
return;
}
log(5, str, null);
}
@Override // okhttp3.internal.platform.Platform
public boolean isCleartextTrafficPermitted(String str) {
try {
Class<?> cls = Class.forName("android.security.NetworkSecurityPolicy");
return api24IsCleartextTrafficPermitted(str, cls, cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]));
} catch (ClassNotFoundException | NoSuchMethodException unused) {
return super.isCleartextTrafficPermitted(str);
} catch (IllegalAccessException e) {
e = e;
throw new AssertionError("unable to determine cleartext support", e);
} catch (IllegalArgumentException e2) {
e = e2;
throw new AssertionError("unable to determine cleartext support", e);
} catch (InvocationTargetException e3) {
e = e3;
throw new AssertionError("unable to determine cleartext support", e);
}
}
public final boolean api24IsCleartextTrafficPermitted(String str, Class cls, Object obj) {
try {
return ((Boolean) cls.getMethod("isCleartextTrafficPermitted", String.class).invoke(obj, str)).booleanValue();
} catch (NoSuchMethodException unused) {
return api23IsCleartextTrafficPermitted(str, cls, obj);
}
}
public final boolean api23IsCleartextTrafficPermitted(String str, Class cls, Object obj) {
try {
return ((Boolean) cls.getMethod("isCleartextTrafficPermitted", new Class[0]).invoke(obj, new Object[0])).booleanValue();
} catch (NoSuchMethodException unused) {
return super.isCleartextTrafficPermitted(str);
}
}
@Override // okhttp3.internal.platform.Platform
public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager x509TrustManager) {
try {
Class<?> cls = Class.forName("android.net.http.X509TrustManagerExtensions");
return new AndroidCertificateChainCleaner(cls.getConstructor(X509TrustManager.class).newInstance(x509TrustManager), cls.getMethod("checkServerTrusted", X509Certificate[].class, String.class, String.class));
} catch (Exception unused) {
return super.buildCertificateChainCleaner(x509TrustManager);
}
}
public static Platform buildIfSupported() {
if (!Platform.isAndroid()) {
return null;
}
try {
Class<?> cls = Class.forName("com.android.org.conscrypt.SSLParametersImpl");
Class<?> cls2 = Class.forName("com.android.org.conscrypt.OpenSSLSocketImpl");
try {
return new AndroidPlatform(cls, cls2, cls2.getDeclaredMethod("setUseSessionTickets", Boolean.TYPE), cls2.getMethod("setHostname", String.class), cls2.getMethod("getAlpnSelectedProtocol", new Class[0]), cls2.getMethod("setAlpnProtocols", byte[].class));
} catch (NoSuchMethodException unused) {
throw new IllegalStateException("Expected Android API level 21+ but was " + Build.VERSION.SDK_INT);
}
} catch (ClassNotFoundException unused2) {
return null;
}
}
@Override // okhttp3.internal.platform.Platform
public TrustRootIndex buildTrustRootIndex(X509TrustManager x509TrustManager) {
try {
Method declaredMethod = x509TrustManager.getClass().getDeclaredMethod("findTrustAnchorByIssuerAndSignature", X509Certificate.class);
declaredMethod.setAccessible(true);
return new CustomTrustRootIndex(x509TrustManager, declaredMethod);
} catch (NoSuchMethodException unused) {
return super.buildTrustRootIndex(x509TrustManager);
}
}
public static final class AndroidCertificateChainCleaner extends CertificateChainCleaner {
public final Method checkServerTrusted;
public final Object x509TrustManagerExtensions;
public int hashCode() {
return 0;
}
public AndroidCertificateChainCleaner(Object obj, Method method) {
this.x509TrustManagerExtensions = obj;
this.checkServerTrusted = method;
}
@Override // okhttp3.internal.tls.CertificateChainCleaner
public List clean(List list, String str) {
try {
return (List) this.checkServerTrusted.invoke(this.x509TrustManagerExtensions, (X509Certificate[]) list.toArray(new X509Certificate[list.size()]), "RSA", str);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (InvocationTargetException e2) {
SSLPeerUnverifiedException sSLPeerUnverifiedException = new SSLPeerUnverifiedException(e2.getMessage());
sSLPeerUnverifiedException.initCause(e2);
throw sSLPeerUnverifiedException;
}
}
public boolean equals(Object obj) {
return obj instanceof AndroidCertificateChainCleaner;
}
}
public static final class CloseGuard {
public final Method getMethod;
public final Method openMethod;
public final Method warnIfOpenMethod;
public CloseGuard(Method method, Method method2, Method method3) {
this.getMethod = method;
this.openMethod = method2;
this.warnIfOpenMethod = method3;
}
public Object createAndOpen(String str) {
Method method = this.getMethod;
if (method != null) {
try {
Object invoke = method.invoke(null, new Object[0]);
this.openMethod.invoke(invoke, str);
return invoke;
} catch (Exception unused) {
}
}
return null;
}
public boolean warnIfOpen(Object obj) {
if (obj == null) {
return false;
}
try {
this.warnIfOpenMethod.invoke(obj, new Object[0]);
return true;
} catch (Exception unused) {
return false;
}
}
public static CloseGuard get() {
Method method;
Method method2;
Method method3;
try {
Class<?> cls = Class.forName("dalvik.system.CloseGuard");
method = cls.getMethod("get", new Class[0]);
method3 = cls.getMethod(MRAIDPresenter.OPEN, String.class);
method2 = cls.getMethod("warnIfOpen", new Class[0]);
} catch (Exception unused) {
method = null;
method2 = null;
method3 = null;
}
return new CloseGuard(method, method3, method2);
}
}
public static final class CustomTrustRootIndex implements TrustRootIndex {
public final Method findByIssuerAndSignatureMethod;
public final X509TrustManager trustManager;
public CustomTrustRootIndex(X509TrustManager x509TrustManager, Method method) {
this.findByIssuerAndSignatureMethod = method;
this.trustManager = x509TrustManager;
}
@Override // okhttp3.internal.tls.TrustRootIndex
public X509Certificate findByIssuerAndSignature(X509Certificate x509Certificate) {
try {
TrustAnchor trustAnchor = (TrustAnchor) this.findByIssuerAndSignatureMethod.invoke(this.trustManager, x509Certificate);
if (trustAnchor != null) {
return trustAnchor.getTrustedCert();
}
return null;
} catch (IllegalAccessException e) {
throw new AssertionError("unable to get issues and signature", e);
} catch (InvocationTargetException unused) {
return null;
}
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof CustomTrustRootIndex)) {
return false;
}
CustomTrustRootIndex customTrustRootIndex = (CustomTrustRootIndex) obj;
return this.trustManager.equals(customTrustRootIndex.trustManager) && this.findByIssuerAndSignatureMethod.equals(customTrustRootIndex.findByIssuerAndSignatureMethod);
}
public int hashCode() {
return this.trustManager.hashCode() + (this.findByIssuerAndSignatureMethod.hashCode() * 31);
}
}
@Override // okhttp3.internal.platform.Platform
public SSLContext getSSLContext() {
try {
return SSLContext.getInstance("TLS");
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("No TLS provider", e);
}
}
}

View File

@@ -0,0 +1,69 @@
package okhttp3.internal.platform;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import org.conscrypt.Conscrypt;
/* loaded from: classes5.dex */
public class ConscryptPlatform extends Platform {
public final Provider getProvider() {
return Conscrypt.newProviderBuilder().provideTrustManager().build();
}
@Override // okhttp3.internal.platform.Platform
public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) {
if (Conscrypt.isConscrypt(sSLSocket)) {
if (str != null) {
Conscrypt.setUseSessionTickets(sSLSocket, true);
Conscrypt.setHostname(sSLSocket, str);
}
Conscrypt.setApplicationProtocols(sSLSocket, (String[]) Platform.alpnProtocolNames(list).toArray(new String[0]));
return;
}
super.configureTlsExtensions(sSLSocket, str, list);
}
@Override // okhttp3.internal.platform.Platform
public String getSelectedProtocol(SSLSocket sSLSocket) {
if (Conscrypt.isConscrypt(sSLSocket)) {
return Conscrypt.getApplicationProtocol(sSLSocket);
}
return super.getSelectedProtocol(sSLSocket);
}
@Override // okhttp3.internal.platform.Platform
public SSLContext getSSLContext() {
try {
return SSLContext.getInstance("TLSv1.3", getProvider());
} catch (NoSuchAlgorithmException e) {
try {
return SSLContext.getInstance("TLS", getProvider());
} catch (NoSuchAlgorithmException unused) {
throw new IllegalStateException("No TLS provider", e);
}
}
}
public static ConscryptPlatform buildIfSupported() {
try {
Class.forName("org.conscrypt.Conscrypt");
if (Conscrypt.isAvailable()) {
return new ConscryptPlatform();
}
return null;
} catch (ClassNotFoundException unused) {
return null;
}
}
@Override // okhttp3.internal.platform.Platform
public void configureSslSocketFactory(SSLSocketFactory sSLSocketFactory) {
if (Conscrypt.isConscrypt(sSLSocketFactory)) {
Conscrypt.setUseEngineSocket(sSLSocketFactory, true);
}
}
}

View File

@@ -0,0 +1,128 @@
package okhttp3.internal.platform;
import csdk.gluads.Consts;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import javax.net.ssl.SSLSocket;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public class Jdk8WithJettyBootPlatform extends Platform {
public final Class clientProviderClass;
public final Method getMethod;
public final Method putMethod;
public final Method removeMethod;
public final Class serverProviderClass;
public Jdk8WithJettyBootPlatform(Method method, Method method2, Method method3, Class cls, Class cls2) {
this.putMethod = method;
this.getMethod = method2;
this.removeMethod = method3;
this.clientProviderClass = cls;
this.serverProviderClass = cls2;
}
@Override // okhttp3.internal.platform.Platform
public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) {
try {
this.putMethod.invoke(null, sSLSocket, Proxy.newProxyInstance(Platform.class.getClassLoader(), new Class[]{this.clientProviderClass, this.serverProviderClass}, new AlpnProvider(Platform.alpnProtocolNames(list))));
} catch (IllegalAccessException | InvocationTargetException e) {
throw new AssertionError("failed to set ALPN", e);
}
}
@Override // okhttp3.internal.platform.Platform
public void afterHandshake(SSLSocket sSLSocket) {
try {
this.removeMethod.invoke(null, sSLSocket);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new AssertionError("failed to remove ALPN", e);
}
}
@Override // okhttp3.internal.platform.Platform
public String getSelectedProtocol(SSLSocket sSLSocket) {
try {
AlpnProvider alpnProvider = (AlpnProvider) Proxy.getInvocationHandler(this.getMethod.invoke(null, sSLSocket));
boolean z = alpnProvider.unsupported;
if (!z && alpnProvider.selected == null) {
Platform.get().log(4, "ALPN callback dropped: HTTP/2 is disabled. Is alpn-boot on the boot class path?", null);
return null;
}
if (z) {
return null;
}
return alpnProvider.selected;
} catch (IllegalAccessException e) {
e = e;
throw new AssertionError("failed to get ALPN selected protocol", e);
} catch (InvocationTargetException e2) {
e = e2;
throw new AssertionError("failed to get ALPN selected protocol", e);
}
}
public static Platform buildIfSupported() {
try {
Class<?> cls = Class.forName("org.eclipse.jetty.alpn.ALPN", true, null);
Class<?> cls2 = Class.forName("org.eclipse.jetty.alpn.ALPN$Provider", true, null);
return new Jdk8WithJettyBootPlatform(cls.getMethod("put", SSLSocket.class, cls2), cls.getMethod("get", SSLSocket.class), cls.getMethod("remove", SSLSocket.class), Class.forName("org.eclipse.jetty.alpn.ALPN$ClientProvider", true, null), Class.forName("org.eclipse.jetty.alpn.ALPN$ServerProvider", true, null));
} catch (ClassNotFoundException | NoSuchMethodException unused) {
return null;
}
}
public static class AlpnProvider implements InvocationHandler {
public final List protocols;
public String selected;
public boolean unsupported;
public AlpnProvider(List list) {
this.protocols = list;
}
@Override // java.lang.reflect.InvocationHandler
public Object invoke(Object obj, Method method, Object[] objArr) {
String name = method.getName();
Class<?> returnType = method.getReturnType();
if (objArr == null) {
objArr = Util.EMPTY_STRING_ARRAY;
}
if (name.equals("supports") && Boolean.TYPE == returnType) {
return Boolean.TRUE;
}
if (name.equals(Consts.SDK_PRIVACY_STAGE_UNSUPPORTED) && Void.TYPE == returnType) {
this.unsupported = true;
return null;
}
if (name.equals("protocols") && objArr.length == 0) {
return this.protocols;
}
if ((name.equals("selectProtocol") || name.equals("select")) && String.class == returnType && objArr.length == 1) {
Object obj2 = objArr[0];
if (obj2 instanceof List) {
List list = (List) obj2;
int size = list.size();
for (int i = 0; i < size; i++) {
String str = (String) list.get(i);
if (this.protocols.contains(str)) {
this.selected = str;
return str;
}
}
String str2 = (String) this.protocols.get(0);
this.selected = str2;
return str2;
}
}
if ((name.equals("protocolSelected") || name.equals("selected")) && objArr.length == 1) {
this.selected = (String) objArr[0];
return null;
}
return method.invoke(this, objArr);
}
}
}

View File

@@ -0,0 +1,58 @@
package okhttp3.internal.platform;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
/* loaded from: classes5.dex */
public final class Jdk9Platform extends Platform {
public final Method getProtocolMethod;
public final Method setProtocolMethod;
public Jdk9Platform(Method method, Method method2) {
this.setProtocolMethod = method;
this.getProtocolMethod = method2;
}
@Override // okhttp3.internal.platform.Platform
public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) {
try {
SSLParameters sSLParameters = sSLSocket.getSSLParameters();
List alpnProtocolNames = Platform.alpnProtocolNames(list);
this.setProtocolMethod.invoke(sSLParameters, alpnProtocolNames.toArray(new String[alpnProtocolNames.size()]));
sSLSocket.setSSLParameters(sSLParameters);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new AssertionError("failed to set SSL parameters", e);
}
}
@Override // okhttp3.internal.platform.Platform
public String getSelectedProtocol(SSLSocket sSLSocket) {
try {
String str = (String) this.getProtocolMethod.invoke(sSLSocket, new Object[0]);
if (str != null) {
if (!str.equals("")) {
return str;
}
}
return null;
} catch (IllegalAccessException e) {
throw new AssertionError("failed to get ALPN selected protocol", e);
} catch (InvocationTargetException e2) {
if (e2.getCause() instanceof UnsupportedOperationException) {
return null;
}
throw new AssertionError("failed to get ALPN selected protocol", e2);
}
}
public static Jdk9Platform buildIfSupported() {
try {
return new Jdk9Platform(SSLParameters.class.getMethod("setApplicationProtocols", String[].class), SSLSocket.class.getMethod("getApplicationProtocol", new Class[0]));
} catch (NoSuchMethodException unused) {
return null;
}
}
}

View File

@@ -0,0 +1,163 @@
package okhttp3.internal.platform;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.internal.Util;
import okhttp3.internal.tls.BasicCertificateChainCleaner;
import okhttp3.internal.tls.BasicTrustRootIndex;
import okhttp3.internal.tls.CertificateChainCleaner;
import okhttp3.internal.tls.TrustRootIndex;
import okio.Buffer;
/* loaded from: classes5.dex */
public class Platform {
public static final Platform PLATFORM = findPlatform();
public static final Logger logger = Logger.getLogger(OkHttpClient.class.getName());
public static Platform get() {
return PLATFORM;
}
public void afterHandshake(SSLSocket sSLSocket) {
}
public void configureSslSocketFactory(SSLSocketFactory sSLSocketFactory) {
}
public void configureTlsExtensions(SSLSocket sSLSocket, String str, List list) {
}
public String getPrefix() {
return "OkHttp";
}
public String getSelectedProtocol(SSLSocket sSLSocket) {
return null;
}
public boolean isCleartextTrafficPermitted(String str) {
return true;
}
public void connectSocket(Socket socket, InetSocketAddress inetSocketAddress, int i) {
socket.connect(inetSocketAddress, i);
}
public void log(int i, String str, Throwable th) {
logger.log(i == 5 ? Level.WARNING : Level.INFO, str, th);
}
public Object getStackTraceForCloseable(String str) {
if (logger.isLoggable(Level.FINE)) {
return new Throwable(str);
}
return null;
}
public void logCloseableLeak(String str, Object obj) {
if (obj == null) {
str = str + " To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);";
}
log(5, str, (Throwable) obj);
}
public static List alpnProtocolNames(List list) {
ArrayList arrayList = new ArrayList(list.size());
int size = list.size();
for (int i = 0; i < size; i++) {
Protocol protocol = (Protocol) list.get(i);
if (protocol != Protocol.HTTP_1_0) {
arrayList.add(protocol.toString());
}
}
return arrayList;
}
public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager x509TrustManager) {
return new BasicCertificateChainCleaner(buildTrustRootIndex(x509TrustManager));
}
public static boolean isConscryptPreferred() {
if ("conscrypt".equals(Util.getSystemProperty("okhttp.platform", null))) {
return true;
}
return "Conscrypt".equals(Security.getProviders()[0].getName());
}
public static Platform findPlatform() {
if (isAndroid()) {
return findAndroidPlatform();
}
return findJvmPlatform();
}
public static boolean isAndroid() {
return "Dalvik".equals(System.getProperty("java.vm.name"));
}
public static Platform findJvmPlatform() {
ConscryptPlatform buildIfSupported;
if (isConscryptPreferred() && (buildIfSupported = ConscryptPlatform.buildIfSupported()) != null) {
return buildIfSupported;
}
Jdk9Platform buildIfSupported2 = Jdk9Platform.buildIfSupported();
if (buildIfSupported2 != null) {
return buildIfSupported2;
}
Platform buildIfSupported3 = Jdk8WithJettyBootPlatform.buildIfSupported();
return buildIfSupported3 != null ? buildIfSupported3 : new Platform();
}
public static Platform findAndroidPlatform() {
Platform buildIfSupported = Android10Platform.buildIfSupported();
if (buildIfSupported != null) {
return buildIfSupported;
}
Platform buildIfSupported2 = AndroidPlatform.buildIfSupported();
if (buildIfSupported2 != null) {
return buildIfSupported2;
}
throw new NullPointerException("No platform found on Android");
}
public static byte[] concatLengthPrefixed(List list) {
Buffer buffer = new Buffer();
int size = list.size();
for (int i = 0; i < size; i++) {
Protocol protocol = (Protocol) list.get(i);
if (protocol != Protocol.HTTP_1_0) {
buffer.writeByte(protocol.toString().length());
buffer.writeUtf8(protocol.toString());
}
}
return buffer.readByteArray();
}
public SSLContext getSSLContext() {
try {
return SSLContext.getInstance("TLS");
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("No TLS provider", e);
}
}
public TrustRootIndex buildTrustRootIndex(X509TrustManager x509TrustManager) {
return new BasicTrustRootIndex(x509TrustManager.getAcceptedIssuers());
}
public String toString() {
return getClass().getSimpleName();
}
}

View File

@@ -0,0 +1,24 @@
package okhttp3.internal.proxy;
import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.Collections;
import java.util.List;
/* loaded from: classes5.dex */
public class NullProxySelector extends ProxySelector {
@Override // java.net.ProxySelector
public void connectFailed(URI uri, SocketAddress socketAddress, IOException iOException) {
}
@Override // java.net.ProxySelector
public List select(URI uri) {
if (uri == null) {
throw new IllegalArgumentException("uri must not be null");
}
return Collections.singletonList(Proxy.NO_PROXY);
}
}

View File

@@ -0,0 +1,272 @@
package okhttp3.internal.publicsuffix;
import androidx.webkit.ProxyConfig;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.net.IDN;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import okhttp3.internal.platform.Platform;
import okio.BufferedSource;
import okio.GzipSource;
import okio.Okio;
/* loaded from: classes5.dex */
public final class PublicSuffixDatabase {
public byte[] publicSuffixExceptionListBytes;
public byte[] publicSuffixListBytes;
public static final byte[] WILDCARD_LABEL = {42};
public static final String[] EMPTY_RULE = new String[0];
public static final String[] PREVAILING_RULE = {ProxyConfig.MATCH_ALL_SCHEMES};
public static final PublicSuffixDatabase instance = new PublicSuffixDatabase();
public final AtomicBoolean listRead = new AtomicBoolean(false);
public final CountDownLatch readCompleteLatch = new CountDownLatch(1);
public static PublicSuffixDatabase get() {
return instance;
}
public String getEffectiveTldPlusOne(String str) {
int length;
int length2;
if (str == null) {
throw new NullPointerException("domain == null");
}
String[] split = IDN.toUnicode(str).split("\\.");
String[] findMatchingRule = findMatchingRule(split);
if (split.length == findMatchingRule.length && findMatchingRule[0].charAt(0) != '!') {
return null;
}
if (findMatchingRule[0].charAt(0) == '!') {
length = split.length;
length2 = findMatchingRule.length;
} else {
length = split.length;
length2 = findMatchingRule.length + 1;
}
StringBuilder sb = new StringBuilder();
String[] split2 = str.split("\\.");
for (int i = length - length2; i < split2.length; i++) {
sb.append(split2[i]);
sb.append('.');
}
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
public final String[] findMatchingRule(String[] strArr) {
String str;
String str2;
String str3;
int i = 0;
if (!this.listRead.get() && this.listRead.compareAndSet(false, true)) {
readTheListUninterruptibly();
} else {
try {
this.readCompleteLatch.await();
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
}
synchronized (this) {
if (this.publicSuffixListBytes == null) {
throw new IllegalStateException("Unable to load publicsuffixes.gz resource from the classpath.");
}
}
int length = strArr.length;
byte[][] bArr = new byte[length][];
for (int i2 = 0; i2 < strArr.length; i2++) {
bArr[i2] = strArr[i2].getBytes(StandardCharsets.UTF_8);
}
int i3 = 0;
while (true) {
str = null;
if (i3 >= length) {
str2 = null;
break;
}
str2 = binarySearchBytes(this.publicSuffixListBytes, bArr, i3);
if (str2 != null) {
break;
}
i3++;
}
if (length > 1) {
byte[][] bArr2 = (byte[][]) bArr.clone();
for (int i4 = 0; i4 < bArr2.length - 1; i4++) {
bArr2[i4] = WILDCARD_LABEL;
str3 = binarySearchBytes(this.publicSuffixListBytes, bArr2, i4);
if (str3 != null) {
break;
}
}
}
str3 = null;
if (str3 != null) {
while (true) {
if (i >= length - 1) {
break;
}
String binarySearchBytes = binarySearchBytes(this.publicSuffixExceptionListBytes, bArr, i);
if (binarySearchBytes != null) {
str = binarySearchBytes;
break;
}
i++;
}
}
if (str != null) {
return ("!" + str).split("\\.");
}
if (str2 == null && str3 == null) {
return PREVAILING_RULE;
}
String[] split = str2 != null ? str2.split("\\.") : EMPTY_RULE;
String[] split2 = str3 != null ? str3.split("\\.") : EMPTY_RULE;
return split.length > split2.length ? split : split2;
}
public static String binarySearchBytes(byte[] bArr, byte[][] bArr2, int i) {
int i2;
boolean z;
int i3;
int i4;
int length = bArr.length;
int i5 = 0;
while (i5 < length) {
int i6 = (i5 + length) / 2;
while (i6 > -1 && bArr[i6] != 10) {
i6--;
}
int i7 = i6 + 1;
int i8 = 1;
while (true) {
i2 = i7 + i8;
if (bArr[i2] == 10) {
break;
}
i8++;
}
int i9 = i2 - i7;
int i10 = i;
boolean z2 = false;
int i11 = 0;
int i12 = 0;
while (true) {
if (z2) {
i3 = 46;
z = false;
} else {
z = z2;
i3 = bArr2[i10][i11] & 255;
}
i4 = i3 - (bArr[i7 + i12] & 255);
if (i4 == 0) {
i12++;
i11++;
if (i12 == i9) {
break;
}
if (bArr2[i10].length != i11) {
z2 = z;
} else {
if (i10 == bArr2.length - 1) {
break;
}
i10++;
i11 = -1;
z2 = true;
}
} else {
break;
}
}
if (i4 >= 0) {
if (i4 <= 0) {
int i13 = i9 - i12;
int length2 = bArr2[i10].length - i11;
while (true) {
i10++;
if (i10 >= bArr2.length) {
break;
}
length2 += bArr2[i10].length;
}
if (length2 >= i13) {
if (length2 <= i13) {
return new String(bArr, i7, i9, StandardCharsets.UTF_8);
}
}
}
i5 = i2 + 1;
}
length = i6;
}
return null;
}
public final void readTheListUninterruptibly() {
boolean z = false;
while (true) {
try {
try {
readTheList();
break;
} catch (InterruptedIOException unused) {
Thread.interrupted();
z = true;
} catch (IOException e) {
Platform.get().log(5, "Failed to read public suffix list", e);
if (z) {
Thread.currentThread().interrupt();
return;
}
return;
}
} catch (Throwable th) {
if (z) {
Thread.currentThread().interrupt();
}
throw th;
}
}
if (z) {
Thread.currentThread().interrupt();
}
}
public final void readTheList() {
InputStream resourceAsStream = PublicSuffixDatabase.class.getResourceAsStream(com.mbridge.msdk.thrid.okhttp.internal.publicsuffix.PublicSuffixDatabase.PUBLIC_SUFFIX_RESOURCE);
if (resourceAsStream == null) {
return;
}
BufferedSource buffer = Okio.buffer(new GzipSource(Okio.source(resourceAsStream)));
try {
byte[] bArr = new byte[buffer.readInt()];
buffer.readFully(bArr);
byte[] bArr2 = new byte[buffer.readInt()];
buffer.readFully(bArr2);
buffer.close();
synchronized (this) {
this.publicSuffixListBytes = bArr;
this.publicSuffixExceptionListBytes = bArr2;
}
this.readCompleteLatch.countDown();
} catch (Throwable th) {
try {
throw th;
} catch (Throwable th2) {
if (buffer != null) {
try {
buffer.close();
} catch (Throwable th3) {
th.addSuppressed(th3);
}
}
throw th2;
}
}
}
}

View File

@@ -0,0 +1,77 @@
package okhttp3.internal.tls;
import java.security.GeneralSecurityException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.net.ssl.SSLPeerUnverifiedException;
/* loaded from: classes5.dex */
public final class BasicCertificateChainCleaner extends CertificateChainCleaner {
public final TrustRootIndex trustRootIndex;
public BasicCertificateChainCleaner(TrustRootIndex trustRootIndex) {
this.trustRootIndex = trustRootIndex;
}
@Override // okhttp3.internal.tls.CertificateChainCleaner
public List clean(List list, String str) {
ArrayDeque arrayDeque = new ArrayDeque(list);
ArrayList arrayList = new ArrayList();
arrayList.add((Certificate) arrayDeque.removeFirst());
boolean z = false;
for (int i = 0; i < 9; i++) {
X509Certificate x509Certificate = (X509Certificate) arrayList.get(arrayList.size() - 1);
X509Certificate findByIssuerAndSignature = this.trustRootIndex.findByIssuerAndSignature(x509Certificate);
if (findByIssuerAndSignature != null) {
if (arrayList.size() > 1 || !x509Certificate.equals(findByIssuerAndSignature)) {
arrayList.add(findByIssuerAndSignature);
}
if (verifySignature(findByIssuerAndSignature, findByIssuerAndSignature)) {
return arrayList;
}
z = true;
} else {
Iterator it = arrayDeque.iterator();
while (it.hasNext()) {
X509Certificate x509Certificate2 = (X509Certificate) it.next();
if (verifySignature(x509Certificate, x509Certificate2)) {
it.remove();
arrayList.add(x509Certificate2);
}
}
if (z) {
return arrayList;
}
throw new SSLPeerUnverifiedException("Failed to find a trusted cert that signed " + x509Certificate);
}
}
throw new SSLPeerUnverifiedException("Certificate chain too long: " + arrayList);
}
public final boolean verifySignature(X509Certificate x509Certificate, X509Certificate x509Certificate2) {
if (!x509Certificate.getIssuerDN().equals(x509Certificate2.getSubjectDN())) {
return false;
}
try {
x509Certificate.verify(x509Certificate2.getPublicKey());
return true;
} catch (GeneralSecurityException unused) {
return false;
}
}
public int hashCode() {
return this.trustRootIndex.hashCode();
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
return (obj instanceof BasicCertificateChainCleaner) && ((BasicCertificateChainCleaner) obj).trustRootIndex.equals(this.trustRootIndex);
}
}

View File

@@ -0,0 +1,52 @@
package okhttp3.internal.tls;
import java.security.cert.X509Certificate;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import javax.security.auth.x500.X500Principal;
/* loaded from: classes5.dex */
public final class BasicTrustRootIndex implements TrustRootIndex {
public final Map subjectToCaCerts = new LinkedHashMap();
public BasicTrustRootIndex(X509Certificate... x509CertificateArr) {
for (X509Certificate x509Certificate : x509CertificateArr) {
X500Principal subjectX500Principal = x509Certificate.getSubjectX500Principal();
Set set = (Set) this.subjectToCaCerts.get(subjectX500Principal);
if (set == null) {
set = new LinkedHashSet(1);
this.subjectToCaCerts.put(subjectX500Principal, set);
}
set.add(x509Certificate);
}
}
@Override // okhttp3.internal.tls.TrustRootIndex
public X509Certificate findByIssuerAndSignature(X509Certificate x509Certificate) {
Set<X509Certificate> set = (Set) this.subjectToCaCerts.get(x509Certificate.getIssuerX500Principal());
if (set == null) {
return null;
}
for (X509Certificate x509Certificate2 : set) {
try {
x509Certificate.verify(x509Certificate2.getPublicKey());
return x509Certificate2;
} catch (Exception unused) {
}
}
return null;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
return (obj instanceof BasicTrustRootIndex) && ((BasicTrustRootIndex) obj).subjectToCaCerts.equals(this.subjectToCaCerts);
}
public int hashCode() {
return this.subjectToCaCerts.hashCode();
}
}

View File

@@ -0,0 +1,14 @@
package okhttp3.internal.tls;
import java.util.List;
import javax.net.ssl.X509TrustManager;
import okhttp3.internal.platform.Platform;
/* loaded from: classes5.dex */
public abstract class CertificateChainCleaner {
public abstract List clean(List list, String str);
public static CertificateChainCleaner get(X509TrustManager x509TrustManager) {
return Platform.get().buildCertificateChainCleaner(x509TrustManager);
}
}

View File

@@ -0,0 +1,113 @@
package okhttp3.internal.tls;
import androidx.webkit.ProxyConfig;
import csdk.gluads.Consts;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import okhttp3.internal.Util;
/* loaded from: classes5.dex */
public final class OkHostnameVerifier implements HostnameVerifier {
public static final OkHostnameVerifier INSTANCE = new OkHostnameVerifier();
@Override // javax.net.ssl.HostnameVerifier
public boolean verify(String str, SSLSession sSLSession) {
try {
return verify(str, (X509Certificate) sSLSession.getPeerCertificates()[0]);
} catch (SSLException unused) {
return false;
}
}
public boolean verify(String str, X509Certificate x509Certificate) {
if (Util.verifyAsIpAddress(str)) {
return verifyIpAddress(str, x509Certificate);
}
return verifyHostname(str, x509Certificate);
}
public final boolean verifyIpAddress(String str, X509Certificate x509Certificate) {
List subjectAltNames = getSubjectAltNames(x509Certificate, 7);
int size = subjectAltNames.size();
for (int i = 0; i < size; i++) {
if (str.equalsIgnoreCase((String) subjectAltNames.get(i))) {
return true;
}
}
return false;
}
public final boolean verifyHostname(String str, X509Certificate x509Certificate) {
String lowerCase = str.toLowerCase(Locale.US);
Iterator it = getSubjectAltNames(x509Certificate, 2).iterator();
while (it.hasNext()) {
if (verifyHostname(lowerCase, (String) it.next())) {
return true;
}
}
return false;
}
public static List allSubjectAltNames(X509Certificate x509Certificate) {
List subjectAltNames = getSubjectAltNames(x509Certificate, 7);
List subjectAltNames2 = getSubjectAltNames(x509Certificate, 2);
ArrayList arrayList = new ArrayList(subjectAltNames.size() + subjectAltNames2.size());
arrayList.addAll(subjectAltNames);
arrayList.addAll(subjectAltNames2);
return arrayList;
}
public static List getSubjectAltNames(X509Certificate x509Certificate, int i) {
Integer num;
String str;
ArrayList arrayList = new ArrayList();
try {
Collection<List<?>> subjectAlternativeNames = x509Certificate.getSubjectAlternativeNames();
if (subjectAlternativeNames == null) {
return Collections.emptyList();
}
for (List<?> list : subjectAlternativeNames) {
if (list != null && list.size() >= 2 && (num = (Integer) list.get(0)) != null && num.intValue() == i && (str = (String) list.get(1)) != null) {
arrayList.add(str);
}
}
return arrayList;
} catch (CertificateParsingException unused) {
return Collections.emptyList();
}
}
public boolean verifyHostname(String str, String str2) {
if (str != null && str.length() != 0 && !str.startsWith(Consts.STRING_PERIOD) && !str.endsWith("..") && str2 != null && str2.length() != 0 && !str2.startsWith(Consts.STRING_PERIOD) && !str2.endsWith("..")) {
if (!str.endsWith(Consts.STRING_PERIOD)) {
str = str + '.';
}
if (!str2.endsWith(Consts.STRING_PERIOD)) {
str2 = str2 + '.';
}
String lowerCase = str2.toLowerCase(Locale.US);
if (!lowerCase.contains(ProxyConfig.MATCH_ALL_SCHEMES)) {
return str.equals(lowerCase);
}
if (!lowerCase.startsWith("*.") || lowerCase.indexOf(42, 1) != -1 || str.length() < lowerCase.length() || "*.".equals(lowerCase)) {
return false;
}
String substring = lowerCase.substring(1);
if (!str.endsWith(substring)) {
return false;
}
int length = str.length() - substring.length();
return length <= 0 || str.lastIndexOf(46, length - 1) == -1;
}
return false;
}
}

View File

@@ -0,0 +1,8 @@
package okhttp3.internal.tls;
import java.security.cert.X509Certificate;
/* loaded from: classes5.dex */
public interface TrustRootIndex {
X509Certificate findByIssuerAndSignature(X509Certificate x509Certificate);
}