CrackMe.apk
Download file
package okhttp3.internal.http2;
import androidx.autofill.HintConstants;
import androidx.browser.trusted.sharing.ShareTarget;
import com.facebook.common.util.UriUtil;
import expo.modules.interfaces.permissions.PermissionsResponse;
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 kotlin.Metadata;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.internal.Util;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import okio.Okio;
import okio.Source;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0002\b\t\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0002\b\t\bÆ\u0002\u0018\u00002\u00020\u0001:\u0002\u0018\u0019B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\u0015\u001a\u00020\u00052\u0006\u0010\u0016\u001a\u00020\u0005J\u0014\u0010\u0017\u001a\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004H\u0002R\u001d\u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0005\u0012\u0004\u0012\u00020\u00060\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u000e\u0010\t\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u0019\u0010\u000f\u001a\b\u0012\u0004\u0012\u00020\u00110\u0010¢\u0006\n\n\u0002\u0010\u0014\u001a\u0004\b\u0012\u0010\u0013¨\u0006\u001a"}, d2 = {"Lokhttp3/internal/http2/Hpack;", "", "()V", "NAME_TO_FIRST_INDEX", "", "Lokio/ByteString;", "", "getNAME_TO_FIRST_INDEX", "()Ljava/util/Map;", "PREFIX_4_BITS", "PREFIX_5_BITS", "PREFIX_6_BITS", "PREFIX_7_BITS", "SETTINGS_HEADER_TABLE_SIZE", "SETTINGS_HEADER_TABLE_SIZE_LIMIT", "STATIC_HEADER_TABLE", "", "Lokhttp3/internal/http2/Header;", "getSTATIC_HEADER_TABLE", "()[Lokhttp3/internal/http2/Header;", "[Lokhttp3/internal/http2/Header;", "checkLowercase", "name", "nameToFirstIndex", "Reader", "Writer", "okhttp"}, k = 1, mv = {1, 4, 0})
/* compiled from: Hpack.kt */
public final class Hpack {
public static final Hpack INSTANCE;
private static final Map<ByteString, Integer> NAME_TO_FIRST_INDEX;
private static final int PREFIX_4_BITS = 15;
private static final int PREFIX_5_BITS = 31;
private static final int PREFIX_6_BITS = 63;
private static final int PREFIX_7_BITS = 127;
private static final int SETTINGS_HEADER_TABLE_SIZE = 4096;
private static final int SETTINGS_HEADER_TABLE_SIZE_LIMIT = 16384;
private static final Header[] STATIC_HEADER_TABLE = {new Header(Header.TARGET_AUTHORITY, ""), new Header(Header.TARGET_METHOD, (String) ShareTarget.METHOD_GET), new Header(Header.TARGET_METHOD, (String) ShareTarget.METHOD_POST), new Header(Header.TARGET_PATH, "/"), new Header(Header.TARGET_PATH, "/index.html"), new Header(Header.TARGET_SCHEME, (String) UriUtil.HTTP_SCHEME), new Header(Header.TARGET_SCHEME, (String) UriUtil.HTTPS_SCHEME), new Header(Header.RESPONSE_STATUS, "200"), new Header(Header.RESPONSE_STATUS, "204"), new Header(Header.RESPONSE_STATUS, "206"), new Header(Header.RESPONSE_STATUS, "304"), new Header(Header.RESPONSE_STATUS, "400"), new Header(Header.RESPONSE_STATUS, "404"), new Header(Header.RESPONSE_STATUS, "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("etag", ""), new Header("expect", ""), new Header((String) PermissionsResponse.EXPIRES_KEY, ""), 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((String) SessionDescription.ATTR_RANGE, ""), new Header("referer", ""), new Header("refresh", ""), new Header("retry-after", ""), new Header("server", ""), 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", "")};
static {
Hpack hpack = new Hpack();
INSTANCE = hpack;
NAME_TO_FIRST_INDEX = hpack.nameToFirstIndex();
}
private Hpack() {
}
public final Header[] getSTATIC_HEADER_TABLE() {
return STATIC_HEADER_TABLE;
}
public final Map<ByteString, Integer> getNAME_TO_FIRST_INDEX() {
return NAME_TO_FIRST_INDEX;
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000N\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010!\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0010 \n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\r\u0018\u00002\u00020\u0001B!\b\u0007\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0005¢\u0006\u0002\u0010\u0007J\b\u0010\u0012\u001a\u00020\u0013H\u0002J\b\u0010\u0014\u001a\u00020\u0013H\u0002J\u0010\u0010\u0015\u001a\u00020\u00052\u0006\u0010\u0016\u001a\u00020\u0005H\u0002J\u0010\u0010\u0017\u001a\u00020\u00052\u0006\u0010\u0018\u001a\u00020\u0005H\u0002J\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\n0\u001aJ\u0010\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u0016\u001a\u00020\u0005H\u0002J\u0018\u0010\u001d\u001a\u00020\u00132\u0006\u0010\u0016\u001a\u00020\u00052\u0006\u0010\u001e\u001a\u00020\nH\u0002J\u0010\u0010\u001f\u001a\u00020 2\u0006\u0010\u0016\u001a\u00020\u0005H\u0002J\u0006\u0010\u0006\u001a\u00020\u0005J\b\u0010!\u001a\u00020\u0005H\u0002J\u0006\u0010\"\u001a\u00020\u001cJ\u0006\u0010#\u001a\u00020\u0013J\u0010\u0010$\u001a\u00020\u00132\u0006\u0010\u0016\u001a\u00020\u0005H\u0002J\u0016\u0010%\u001a\u00020\u00052\u0006\u0010&\u001a\u00020\u00052\u0006\u0010'\u001a\u00020\u0005J\u0010\u0010(\u001a\u00020\u00132\u0006\u0010)\u001a\u00020\u0005H\u0002J\b\u0010*\u001a\u00020\u0013H\u0002J\u0010\u0010+\u001a\u00020\u00132\u0006\u0010\u0016\u001a\u00020\u0005H\u0002J\b\u0010,\u001a\u00020\u0013H\u0002R\u001c\u0010\b\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\n0\t8\u0006@\u0006X\u000e¢\u0006\u0004\n\u0002\u0010\u000bR\u0012\u0010\f\u001a\u00020\u00058\u0006@\u0006X\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\r\u001a\u00020\u00058\u0006@\u0006X\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\n0\u000fX\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0005X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0005X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0011X\u0004¢\u0006\u0002\n\u0000¨\u0006-"}, d2 = {"Lokhttp3/internal/http2/Hpack$Reader;", "", "source", "Lokio/Source;", "headerTableSizeSetting", "", "maxDynamicTableByteCount", "(Lokio/Source;II)V", "dynamicTable", "", "Lokhttp3/internal/http2/Header;", "[Lokhttp3/internal/http2/Header;", "dynamicTableByteCount", "headerCount", "headerList", "", "nextHeaderIndex", "Lokio/BufferedSource;", "adjustDynamicTableByteCount", "", "clearDynamicTable", "dynamicTableIndex", "index", "evictToRecoverBytes", "bytesToRecover", "getAndResetHeaderList", "", "getName", "Lokio/ByteString;", "insertIntoDynamicTable", "entry", "isStaticHeader", "", "readByte", "readByteString", "readHeaders", "readIndexedHeader", "readInt", "firstByte", "prefixMask", "readLiteralHeaderWithIncrementalIndexingIndexedName", "nameIndex", "readLiteralHeaderWithIncrementalIndexingNewName", "readLiteralHeaderWithoutIndexingIndexedName", "readLiteralHeaderWithoutIndexingNewName", "okhttp"}, k = 1, mv = {1, 4, 0})
/* compiled from: Hpack.kt */
public static final class Reader {
public Header[] dynamicTable;
public int dynamicTableByteCount;
public int headerCount;
private final List<Header> headerList;
private final int headerTableSizeSetting;
private int maxDynamicTableByteCount;
private int nextHeaderIndex;
private final BufferedSource source;
public Reader(Source source2, int i) {
this(source2, i, 0, 4, (DefaultConstructorMarker) null);
}
public Reader(Source source2, int i, int i2) {
Intrinsics.checkNotNullParameter(source2, "source");
this.headerTableSizeSetting = i;
this.maxDynamicTableByteCount = i2;
this.headerList = new ArrayList();
this.source = Okio.buffer(source2);
Header[] headerArr = new Header[8];
this.dynamicTable = headerArr;
this.nextHeaderIndex = headerArr.length - 1;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ Reader(Source source2, int i, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
this(source2, i, (i3 & 4) != 0 ? i : i2);
}
public final List<Header> getAndResetHeaderList() {
List<Header> list = CollectionsKt.toList(this.headerList);
this.headerList.clear();
return list;
}
public final int maxDynamicTableByteCount() {
return this.maxDynamicTableByteCount;
}
private final void adjustDynamicTableByteCount() {
int i = this.maxDynamicTableByteCount;
int i2 = this.dynamicTableByteCount;
if (i >= i2) {
return;
}
if (i == 0) {
clearDynamicTable();
} else {
evictToRecoverBytes(i2 - i);
}
}
private final void clearDynamicTable() {
ArraysKt.fill$default((Object[]) this.dynamicTable, (Object) null, 0, 0, 6, (Object) null);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
}
private 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) {
Header[] headerArr = this.dynamicTable;
System.arraycopy(headerArr, i2 + 1, headerArr, i2 + 1 + i3, this.headerCount);
this.nextHeaderIndex += i3;
} else {
Header header = this.dynamicTable[length];
Intrinsics.checkNotNull(header);
i -= header.hpackSize;
this.dynamicTableByteCount -= header.hpackSize;
this.headerCount--;
i3++;
}
}
Header[] headerArr2 = this.dynamicTable;
System.arraycopy(headerArr2, i2 + 1, headerArr2, i2 + 1 + i3, this.headerCount);
this.nextHeaderIndex += i3;
}
return i3;
}
public final void readHeaders() throws IOException {
while (!this.source.exhausted()) {
int and = Util.and(this.source.readByte(), 255);
if (and == 128) {
throw new IOException("index == 0");
} else if ((and & 128) == 128) {
readIndexedHeader(readInt(and, 127) - 1);
} else if (and == 64) {
readLiteralHeaderWithIncrementalIndexingNewName();
} else if ((and & 64) == 64) {
readLiteralHeaderWithIncrementalIndexingIndexedName(readInt(and, 63) - 1);
} else if ((and & 32) == 32) {
int readInt = readInt(and, 31);
this.maxDynamicTableByteCount = readInt;
if (readInt < 0 || readInt > this.headerTableSizeSetting) {
throw new IOException("Invalid dynamic table size update " + this.maxDynamicTableByteCount);
}
adjustDynamicTableByteCount();
} else if (and == 16 || and == 0) {
readLiteralHeaderWithoutIndexingNewName();
} else {
readLiteralHeaderWithoutIndexingIndexedName(readInt(and, 15) - 1);
}
}
}
private final void readIndexedHeader(int i) throws IOException {
if (isStaticHeader(i)) {
this.headerList.add(Hpack.INSTANCE.getSTATIC_HEADER_TABLE()[i]);
return;
}
int dynamicTableIndex = dynamicTableIndex(i - Hpack.INSTANCE.getSTATIC_HEADER_TABLE().length);
if (dynamicTableIndex >= 0) {
Header[] headerArr = this.dynamicTable;
if (dynamicTableIndex < headerArr.length) {
Header header = headerArr[dynamicTableIndex];
Intrinsics.checkNotNull(header);
this.headerList.add(header);
return;
}
}
throw new IOException("Header index too large " + (i + 1));
}
private final int dynamicTableIndex(int i) {
return this.nextHeaderIndex + 1 + i;
}
private final void readLiteralHeaderWithoutIndexingIndexedName(int i) throws IOException {
this.headerList.add(new Header(getName(i), readByteString()));
}
private final void readLiteralHeaderWithoutIndexingNewName() throws IOException {
this.headerList.add(new Header(Hpack.INSTANCE.checkLowercase(readByteString()), readByteString()));
}
private final void readLiteralHeaderWithIncrementalIndexingIndexedName(int i) throws IOException {
insertIntoDynamicTable(-1, new Header(getName(i), readByteString()));
}
private final void readLiteralHeaderWithIncrementalIndexingNewName() throws IOException {
insertIntoDynamicTable(-1, new Header(Hpack.INSTANCE.checkLowercase(readByteString()), readByteString()));
}
private final ByteString getName(int i) throws IOException {
if (isStaticHeader(i)) {
return Hpack.INSTANCE.getSTATIC_HEADER_TABLE()[i].name;
}
int dynamicTableIndex = dynamicTableIndex(i - Hpack.INSTANCE.getSTATIC_HEADER_TABLE().length);
if (dynamicTableIndex >= 0) {
Header[] headerArr = this.dynamicTable;
if (dynamicTableIndex < headerArr.length) {
Header header = headerArr[dynamicTableIndex];
Intrinsics.checkNotNull(header);
return header.name;
}
}
throw new IOException("Header index too large " + (i + 1));
}
private final boolean isStaticHeader(int i) {
return i >= 0 && i <= Hpack.INSTANCE.getSTATIC_HEADER_TABLE().length - 1;
}
private final void insertIntoDynamicTable(int i, Header header) {
this.headerList.add(header);
int i2 = header.hpackSize;
if (i != -1) {
Header header2 = this.dynamicTable[dynamicTableIndex(i)];
Intrinsics.checkNotNull(header2);
i2 -= header2.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;
}
private final int readByte() throws IOException {
return Util.and(this.source.readByte(), 255);
}
public final int readInt(int i, int i2) throws IOException {
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 final ByteString readByteString() throws IOException {
int readByte = readByte();
boolean z = (readByte & 128) == 128;
long readInt = (long) readInt(readByte, 127);
if (!z) {
return this.source.readByteString(readInt);
}
Buffer buffer = new Buffer();
Huffman.INSTANCE.decode(this.source, readInt, buffer);
return buffer.readByteString();
}
}
private final Map<ByteString, Integer> nameToFirstIndex() {
Header[] headerArr = STATIC_HEADER_TABLE;
LinkedHashMap linkedHashMap = new LinkedHashMap(headerArr.length);
int length = headerArr.length;
for (int i = 0; i < length; i++) {
Header[] headerArr2 = STATIC_HEADER_TABLE;
if (!linkedHashMap.containsKey(headerArr2[i].name)) {
linkedHashMap.put(headerArr2[i].name, Integer.valueOf(i));
}
}
Map<ByteString, Integer> unmodifiableMap = Collections.unmodifiableMap(linkedHashMap);
Intrinsics.checkNotNullExpressionValue(unmodifiableMap, "Collections.unmodifiableMap(result)");
return unmodifiableMap;
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\b\u0005\u0018\u00002\u00020\u0001B#\b\u0007\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJ\b\u0010\u0013\u001a\u00020\u0014H\u0002J\b\u0010\u0015\u001a\u00020\u0014H\u0002J\u0010\u0010\u0016\u001a\u00020\u00032\u0006\u0010\u0017\u001a\u00020\u0003H\u0002J\u0010\u0010\u0018\u001a\u00020\u00142\u0006\u0010\u0019\u001a\u00020\u000bH\u0002J\u000e\u0010\u001a\u001a\u00020\u00142\u0006\u0010\u0002\u001a\u00020\u0003J\u000e\u0010\u001b\u001a\u00020\u00142\u0006\u0010\u001c\u001a\u00020\u001dJ\u0014\u0010\u001e\u001a\u00020\u00142\f\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\u000b0 J\u001e\u0010!\u001a\u00020\u00142\u0006\u0010\"\u001a\u00020\u00032\u0006\u0010#\u001a\u00020\u00032\u0006\u0010$\u001a\u00020\u0003R\u001c\u0010\t\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u000b0\n8\u0006@\u0006X\u000e¢\u0006\u0004\n\u0002\u0010\fR\u0012\u0010\r\u001a\u00020\u00038\u0006@\u0006X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u0005X\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u000f\u001a\u00020\u00038\u0006@\u0006X\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0002\u001a\u00020\u00038\u0006@\u0006X\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0010\u001a\u00020\u00038\u0006@\u0006X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0003X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0003X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000¨\u0006%"}, d2 = {"Lokhttp3/internal/http2/Hpack$Writer;", "", "headerTableSizeSetting", "", "useCompression", "", "out", "Lokio/Buffer;", "(IZLokio/Buffer;)V", "dynamicTable", "", "Lokhttp3/internal/http2/Header;", "[Lokhttp3/internal/http2/Header;", "dynamicTableByteCount", "emitDynamicTableSizeUpdate", "headerCount", "maxDynamicTableByteCount", "nextHeaderIndex", "smallestHeaderTableSizeSetting", "adjustDynamicTableByteCount", "", "clearDynamicTable", "evictToRecoverBytes", "bytesToRecover", "insertIntoDynamicTable", "entry", "resizeHeaderTable", "writeByteString", "data", "Lokio/ByteString;", "writeHeaders", "headerBlock", "", "writeInt", "value", "prefixMask", "bits", "okhttp"}, k = 1, mv = {1, 4, 0})
/* compiled from: Hpack.kt */
public static final class Writer {
public Header[] dynamicTable;
public int dynamicTableByteCount;
private boolean emitDynamicTableSizeUpdate;
public int headerCount;
public int headerTableSizeSetting;
public int maxDynamicTableByteCount;
private int nextHeaderIndex;
private final Buffer out;
private int smallestHeaderTableSizeSetting;
private final boolean useCompression;
public Writer(int i, Buffer buffer) {
this(i, false, buffer, 2, (DefaultConstructorMarker) null);
}
public Writer(Buffer buffer) {
this(0, false, buffer, 3, (DefaultConstructorMarker) null);
}
public Writer(int i, boolean z, Buffer buffer) {
Intrinsics.checkNotNullParameter(buffer, "out");
this.headerTableSizeSetting = i;
this.useCompression = z;
this.out = buffer;
this.smallestHeaderTableSizeSetting = Integer.MAX_VALUE;
this.maxDynamicTableByteCount = i;
Header[] headerArr = new Header[8];
this.dynamicTable = headerArr;
this.nextHeaderIndex = headerArr.length - 1;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ Writer(int i, boolean z, Buffer buffer, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this((i2 & 1) != 0 ? 4096 : i, (i2 & 2) != 0 ? true : z, buffer);
}
private final void clearDynamicTable() {
ArraysKt.fill$default((Object[]) this.dynamicTable, (Object) null, 0, 0, 6, (Object) null);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
}
private 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) {
Header[] headerArr = this.dynamicTable;
System.arraycopy(headerArr, i2 + 1, headerArr, i2 + 1 + i3, this.headerCount);
Header[] headerArr2 = this.dynamicTable;
int i4 = this.nextHeaderIndex;
Arrays.fill(headerArr2, i4 + 1, i4 + 1 + i3, (Object) null);
this.nextHeaderIndex += i3;
} else {
Header header = this.dynamicTable[length];
Intrinsics.checkNotNull(header);
i -= header.hpackSize;
int i5 = this.dynamicTableByteCount;
Header header2 = this.dynamicTable[length];
Intrinsics.checkNotNull(header2);
this.dynamicTableByteCount = i5 - header2.hpackSize;
this.headerCount--;
i3++;
}
}
Header[] headerArr3 = this.dynamicTable;
System.arraycopy(headerArr3, i2 + 1, headerArr3, i2 + 1 + i3, this.headerCount);
Header[] headerArr22 = this.dynamicTable;
int i42 = this.nextHeaderIndex;
Arrays.fill(headerArr22, i42 + 1, i42 + 1 + i3, (Object) null);
this.nextHeaderIndex += i3;
}
return i3;
}
private 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 final void writeHeaders(List<Header> list) throws IOException {
int i;
int i2;
Intrinsics.checkNotNullParameter(list, "headerBlock");
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 = list.get(i4);
ByteString asciiLowercase = header.name.toAsciiLowercase();
ByteString byteString = header.value;
Integer num = Hpack.INSTANCE.getNAME_TO_FIRST_INDEX().get(asciiLowercase);
if (num != null) {
i2 = num.intValue() + 1;
if (2 <= i2 && 7 >= i2) {
if (Intrinsics.areEqual((Object) Hpack.INSTANCE.getSTATIC_HEADER_TABLE()[i2 - 1].value, (Object) byteString)) {
i = i2;
} else if (Intrinsics.areEqual((Object) Hpack.INSTANCE.getSTATIC_HEADER_TABLE()[i2].value, (Object) byteString)) {
i = i2;
i2++;
}
}
i = i2;
i2 = -1;
} else {
i2 = -1;
i = -1;
}
if (i2 == -1) {
int i5 = this.nextHeaderIndex + 1;
int length = this.dynamicTable.length;
while (true) {
if (i5 >= length) {
break;
}
Header header2 = this.dynamicTable[i5];
Intrinsics.checkNotNull(header2);
if (Intrinsics.areEqual((Object) header2.name, (Object) asciiLowercase)) {
Header header3 = this.dynamicTable[i5];
Intrinsics.checkNotNull(header3);
if (Intrinsics.areEqual((Object) header3.value, (Object) byteString)) {
i2 = Hpack.INSTANCE.getSTATIC_HEADER_TABLE().length + (i5 - this.nextHeaderIndex);
break;
} else if (i == -1) {
i = (i5 - this.nextHeaderIndex) + Hpack.INSTANCE.getSTATIC_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) || !(!Intrinsics.areEqual((Object) Header.TARGET_AUTHORITY, (Object) asciiLowercase))) {
writeInt(i, 63, 64);
writeByteString(byteString);
insertIntoDynamicTable(header);
} else {
writeInt(i, 15, 0);
writeByteString(byteString);
}
}
}
public final 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 final void writeByteString(ByteString byteString) throws IOException {
Intrinsics.checkNotNullParameter(byteString, "data");
if (!this.useCompression || Huffman.INSTANCE.encodedLength(byteString) >= byteString.size()) {
writeInt(byteString.size(), 127, 0);
this.out.write(byteString);
return;
}
Buffer buffer = new Buffer();
Huffman.INSTANCE.encode(byteString, buffer);
ByteString readByteString = buffer.readByteString();
writeInt(readByteString.size(), 127, 128);
this.out.write(readByteString);
}
public final void resizeHeaderTable(int i) {
this.headerTableSizeSetting = i;
int min = Math.min(i, 16384);
int i2 = this.maxDynamicTableByteCount;
if (i2 != min) {
if (min < i2) {
this.smallestHeaderTableSizeSetting = Math.min(this.smallestHeaderTableSizeSetting, min);
}
this.emitDynamicTableSizeUpdate = true;
this.maxDynamicTableByteCount = min;
adjustDynamicTableByteCount();
}
}
private final void adjustDynamicTableByteCount() {
int i = this.maxDynamicTableByteCount;
int i2 = this.dynamicTableByteCount;
if (i >= i2) {
return;
}
if (i == 0) {
clearDynamicTable();
} else {
evictToRecoverBytes(i2 - i);
}
}
}
public final ByteString checkLowercase(ByteString byteString) throws IOException {
Intrinsics.checkNotNullParameter(byteString, HintConstants.AUTOFILL_HINT_NAME);
int size = byteString.size();
for (int i = 0; i < size; i++) {
byte b = (byte) 65;
byte b2 = (byte) 90;
byte b3 = byteString.getByte(i);
if (b <= b3 && b2 >= b3) {
throw new IOException("PROTOCOL_ERROR response malformed: mixed case name: " + byteString.utf8());
}
}
return byteString;
}
}
Download file