328 lines
10 KiB
Java
328 lines
10 KiB
Java
package okhttp3;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import o.C14953gcr;
|
|
import o.C14957gcv;
|
|
import o.gdZ;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class CacheControl {
|
|
private String headerValue;
|
|
private final boolean immutable;
|
|
private final boolean isPrivate;
|
|
private final boolean isPublic;
|
|
private final int maxAgeSeconds;
|
|
private final int maxStaleSeconds;
|
|
private final int minFreshSeconds;
|
|
private final boolean mustRevalidate;
|
|
private final boolean noCache;
|
|
private final boolean noStore;
|
|
private final boolean noTransform;
|
|
private final boolean onlyIfCached;
|
|
private final int sMaxAgeSeconds;
|
|
public static final Companion Companion = new Companion(null);
|
|
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();
|
|
|
|
private 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 final String toString() {
|
|
String str = this.headerValue;
|
|
if (str != null) {
|
|
return str;
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
if (noCache()) {
|
|
sb.append("no-cache, ");
|
|
}
|
|
if (noStore()) {
|
|
sb.append("no-store, ");
|
|
}
|
|
if (maxAgeSeconds() != -1) {
|
|
sb.append("max-age=");
|
|
sb.append(maxAgeSeconds());
|
|
sb.append(", ");
|
|
}
|
|
if (sMaxAgeSeconds() != -1) {
|
|
sb.append("s-maxage=");
|
|
sb.append(sMaxAgeSeconds());
|
|
sb.append(", ");
|
|
}
|
|
if (isPrivate()) {
|
|
sb.append("private, ");
|
|
}
|
|
if (isPublic()) {
|
|
sb.append("public, ");
|
|
}
|
|
if (mustRevalidate()) {
|
|
sb.append("must-revalidate, ");
|
|
}
|
|
if (maxStaleSeconds() != -1) {
|
|
sb.append("max-stale=");
|
|
sb.append(maxStaleSeconds());
|
|
sb.append(", ");
|
|
}
|
|
if (minFreshSeconds() != -1) {
|
|
sb.append("min-fresh=");
|
|
sb.append(minFreshSeconds());
|
|
sb.append(", ");
|
|
}
|
|
if (onlyIfCached()) {
|
|
sb.append("only-if-cached, ");
|
|
}
|
|
if (noTransform()) {
|
|
sb.append("no-transform, ");
|
|
}
|
|
if (immutable()) {
|
|
sb.append("immutable, ");
|
|
}
|
|
if (sb.length() == 0) {
|
|
return "";
|
|
}
|
|
sb.delete(sb.length() - 2, sb.length());
|
|
String obj = sb.toString();
|
|
C14957gcv.c((Object) obj, "");
|
|
this.headerValue = obj;
|
|
return obj;
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static final class Builder {
|
|
private boolean immutable;
|
|
private int maxAgeSeconds = -1;
|
|
private int maxStaleSeconds = -1;
|
|
private int minFreshSeconds = -1;
|
|
private boolean noCache;
|
|
private boolean noStore;
|
|
private boolean noTransform;
|
|
private boolean onlyIfCached;
|
|
|
|
private final int clampToInt(long j) {
|
|
if (j > 2147483647L) {
|
|
return Integer.MAX_VALUE;
|
|
}
|
|
return (int) j;
|
|
}
|
|
|
|
public final Builder noCache() {
|
|
this.noCache = true;
|
|
return this;
|
|
}
|
|
|
|
public final Builder noStore() {
|
|
this.noStore = true;
|
|
return this;
|
|
}
|
|
|
|
public final Builder maxAge(int i, TimeUnit timeUnit) {
|
|
C14957gcv.e(timeUnit, "");
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException(C14957gcv.c("maxAge < 0: ", Integer.valueOf(i)).toString());
|
|
}
|
|
this.maxAgeSeconds = clampToInt(timeUnit.toSeconds(i));
|
|
return this;
|
|
}
|
|
|
|
public final Builder maxStale(int i, TimeUnit timeUnit) {
|
|
C14957gcv.e(timeUnit, "");
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException(C14957gcv.c("maxStale < 0: ", Integer.valueOf(i)).toString());
|
|
}
|
|
this.maxStaleSeconds = clampToInt(timeUnit.toSeconds(i));
|
|
return this;
|
|
}
|
|
|
|
public final Builder minFresh(int i, TimeUnit timeUnit) {
|
|
C14957gcv.e(timeUnit, "");
|
|
if (i < 0) {
|
|
throw new IllegalArgumentException(C14957gcv.c("minFresh < 0: ", Integer.valueOf(i)).toString());
|
|
}
|
|
this.minFreshSeconds = clampToInt(timeUnit.toSeconds(i));
|
|
return this;
|
|
}
|
|
|
|
public final Builder onlyIfCached() {
|
|
this.onlyIfCached = true;
|
|
return this;
|
|
}
|
|
|
|
public final Builder noTransform() {
|
|
this.noTransform = true;
|
|
return this;
|
|
}
|
|
|
|
public final Builder immutable() {
|
|
this.immutable = true;
|
|
return this;
|
|
}
|
|
|
|
public final CacheControl build() {
|
|
return new CacheControl(this.noCache, this.noStore, this.maxAgeSeconds, -1, false, false, false, this.maxStaleSeconds, this.minFreshSeconds, this.onlyIfCached, this.noTransform, this.immutable, null, null);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:10:0x004a */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public final okhttp3.CacheControl parse(okhttp3.Headers r27) {
|
|
/*
|
|
Method dump skipped, instructions count: 421
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: okhttp3.CacheControl.Companion.parse(okhttp3.Headers):okhttp3.CacheControl");
|
|
}
|
|
|
|
static /* synthetic */ int indexOfElement$default(Companion companion, String str, String str2, int i, int i2, Object obj) {
|
|
if ((i2 & 2) != 0) {
|
|
i = 0;
|
|
}
|
|
return companion.indexOfElement(str, str2, i);
|
|
}
|
|
|
|
private final int indexOfElement(String str, String str2, int i) {
|
|
int length = str.length();
|
|
while (i < length) {
|
|
String str3 = str2;
|
|
char charAt = str.charAt(i);
|
|
C14957gcv.e(str3, "");
|
|
if (gdZ.a((CharSequence) str3, charAt, 0, false) >= 0) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return str.length();
|
|
}
|
|
|
|
public /* synthetic */ Companion(C14953gcr c14953gcr) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public final int sMaxAgeSeconds() {
|
|
return this.sMaxAgeSeconds;
|
|
}
|
|
|
|
public final boolean onlyIfCached() {
|
|
return this.onlyIfCached;
|
|
}
|
|
|
|
public final boolean noTransform() {
|
|
return this.noTransform;
|
|
}
|
|
|
|
public final boolean noStore() {
|
|
return this.noStore;
|
|
}
|
|
|
|
public final boolean noCache() {
|
|
return this.noCache;
|
|
}
|
|
|
|
public final boolean mustRevalidate() {
|
|
return this.mustRevalidate;
|
|
}
|
|
|
|
public final int minFreshSeconds() {
|
|
return this.minFreshSeconds;
|
|
}
|
|
|
|
public final int maxStaleSeconds() {
|
|
return this.maxStaleSeconds;
|
|
}
|
|
|
|
public final int maxAgeSeconds() {
|
|
return this.maxAgeSeconds;
|
|
}
|
|
|
|
public final boolean isPublic() {
|
|
return this.isPublic;
|
|
}
|
|
|
|
public final boolean isPrivate() {
|
|
return this.isPrivate;
|
|
}
|
|
|
|
public final boolean immutable() {
|
|
return this.immutable;
|
|
}
|
|
|
|
/* renamed from: -deprecated_sMaxAgeSeconds, reason: not valid java name */
|
|
public final int m378deprecated_sMaxAgeSeconds() {
|
|
return this.sMaxAgeSeconds;
|
|
}
|
|
|
|
/* renamed from: -deprecated_onlyIfCached, reason: not valid java name */
|
|
public final boolean m377deprecated_onlyIfCached() {
|
|
return this.onlyIfCached;
|
|
}
|
|
|
|
/* renamed from: -deprecated_noTransform, reason: not valid java name */
|
|
public final boolean m376deprecated_noTransform() {
|
|
return this.noTransform;
|
|
}
|
|
|
|
/* renamed from: -deprecated_noStore, reason: not valid java name */
|
|
public final boolean m375deprecated_noStore() {
|
|
return this.noStore;
|
|
}
|
|
|
|
/* renamed from: -deprecated_noCache, reason: not valid java name */
|
|
public final boolean m374deprecated_noCache() {
|
|
return this.noCache;
|
|
}
|
|
|
|
/* renamed from: -deprecated_mustRevalidate, reason: not valid java name */
|
|
public final boolean m373deprecated_mustRevalidate() {
|
|
return this.mustRevalidate;
|
|
}
|
|
|
|
/* renamed from: -deprecated_minFreshSeconds, reason: not valid java name */
|
|
public final int m372deprecated_minFreshSeconds() {
|
|
return this.minFreshSeconds;
|
|
}
|
|
|
|
/* renamed from: -deprecated_maxStaleSeconds, reason: not valid java name */
|
|
public final int m371deprecated_maxStaleSeconds() {
|
|
return this.maxStaleSeconds;
|
|
}
|
|
|
|
/* renamed from: -deprecated_maxAgeSeconds, reason: not valid java name */
|
|
public final int m370deprecated_maxAgeSeconds() {
|
|
return this.maxAgeSeconds;
|
|
}
|
|
|
|
/* renamed from: -deprecated_immutable, reason: not valid java name */
|
|
public final boolean m369deprecated_immutable() {
|
|
return this.immutable;
|
|
}
|
|
|
|
public static final CacheControl parse(Headers headers) {
|
|
return Companion.parse(headers);
|
|
}
|
|
|
|
public /* synthetic */ 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, C14953gcr c14953gcr) {
|
|
this(z, z2, i, i2, z3, z4, z5, i3, i4, z6, z7, z8, str);
|
|
}
|
|
}
|