- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
500 lines
21 KiB
Java
500 lines
21 KiB
Java
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;
|
|
}
|
|
}
|