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,7 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class ConnectionShutdownException extends IOException {
}

View File

@@ -0,0 +1,31 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
/* loaded from: classes4.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,59 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.facebook.internal.security.CertificateUtil;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.mbridge.msdk.thrid.okhttp.Headers;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okio.ByteString;
/* loaded from: classes4.dex */
public final class Header {
final int hpackSize;
public final ByteString name;
public final ByteString value;
public static final ByteString PSEUDO_PREFIX = ByteString.encodeUtf8(CertificateUtil.DELIMITER);
public static final String RESPONSE_STATUS_UTF8 = ":status";
public static final ByteString RESPONSE_STATUS = ByteString.encodeUtf8(RESPONSE_STATUS_UTF8);
public static final String TARGET_METHOD_UTF8 = ":method";
public static final ByteString TARGET_METHOD = ByteString.encodeUtf8(TARGET_METHOD_UTF8);
public static final String TARGET_PATH_UTF8 = ":path";
public static final ByteString TARGET_PATH = ByteString.encodeUtf8(TARGET_PATH_UTF8);
public static final String TARGET_SCHEME_UTF8 = ":scheme";
public static final ByteString TARGET_SCHEME = ByteString.encodeUtf8(TARGET_SCHEME_UTF8);
public static final String TARGET_AUTHORITY_UTF8 = ":authority";
public static final ByteString TARGET_AUTHORITY = ByteString.encodeUtf8(TARGET_AUTHORITY_UTF8);
public interface Listener {
void onHeaders(Headers headers);
}
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,512 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.ironsource.zk;
import com.mbridge.msdk.foundation.download.database.DownloadModel;
import com.mbridge.msdk.mbsignalcommon.commonwebview.ToolBar;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okio.Buffer;
import com.mbridge.msdk.thrid.okio.BufferedSource;
import com.mbridge.msdk.thrid.okio.ByteString;
import com.mbridge.msdk.thrid.okio.Okio;
import com.mbridge.msdk.thrid.okio.Source;
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.jvm.internal.ByteCompanionObject;
import org.apache.http.cookie.ClientCookie;
/* loaded from: classes4.dex */
final class Hpack {
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;
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();
}
private Hpack() {
}
public static final class Reader {
Header[] dynamicTable;
int dynamicTableByteCount;
int headerCount;
private final List<Header> headerList;
private final int headerTableSizeSetting;
private int maxDynamicTableByteCount;
int nextHeaderIndex;
private final BufferedSource source;
private int dynamicTableIndex(int i) {
return this.nextHeaderIndex + 1 + i;
}
public int maxDynamicTableByteCount() {
return this.maxDynamicTableByteCount;
}
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);
}
private void adjustDynamicTableByteCount() {
int i = this.maxDynamicTableByteCount;
int i2 = this.dynamicTableByteCount;
if (i < i2) {
if (i == 0) {
clearDynamicTable();
} else {
evictToRecoverBytes(i2 - i);
}
}
}
private void clearDynamicTable() {
Arrays.fill(this.dynamicTable, (Object) null);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
}
private 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() throws IOException {
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<Header> getAndResetHeaderList() {
ArrayList arrayList = new ArrayList(this.headerList);
this.headerList.clear();
return arrayList;
}
private void readIndexedHeader(int i) throws IOException {
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));
}
private void readLiteralHeaderWithoutIndexingIndexedName(int i) throws IOException {
this.headerList.add(new Header(getName(i), readByteString()));
}
private void readLiteralHeaderWithoutIndexingNewName() throws IOException {
this.headerList.add(new Header(Hpack.checkLowercase(readByteString()), readByteString()));
}
private void readLiteralHeaderWithIncrementalIndexingIndexedName(int i) throws IOException {
insertIntoDynamicTable(-1, new Header(getName(i), readByteString()));
}
private void readLiteralHeaderWithIncrementalIndexingNewName() throws IOException {
insertIntoDynamicTable(-1, new Header(Hpack.checkLowercase(readByteString()), readByteString()));
}
private ByteString getName(int i) throws IOException {
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));
}
private boolean isStaticHeader(int i) {
return i >= 0 && i <= Hpack.STATIC_HEADER_TABLE.length - 1;
}
private 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;
}
private int readByte() throws IOException {
return this.source.readByte() & 255;
}
public 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 ByteString readByteString() throws IOException {
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);
}
}
private static Map<ByteString, Integer> 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 {
private static final int SETTINGS_HEADER_TABLE_SIZE = 4096;
private static final int SETTINGS_HEADER_TABLE_SIZE_LIMIT = 16384;
Header[] dynamicTable;
int dynamicTableByteCount;
private boolean emitDynamicTableSizeUpdate;
int headerCount;
int headerTableSizeSetting;
int maxDynamicTableByteCount;
int nextHeaderIndex;
private final Buffer out;
private int smallestHeaderTableSizeSetting;
private 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;
}
private void clearDynamicTable() {
Arrays.fill(this.dynamicTable, (Object) null);
this.nextHeaderIndex = this.dynamicTable.length - 1;
this.headerCount = 0;
this.dynamicTableByteCount = 0;
}
private 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;
}
private 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<Header> list) throws IOException {
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 = list.get(i4);
ByteString asciiLowercase = header.name.toAsciiLowercase();
ByteString byteString = header.value;
Integer num = 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 (Util.equal(headerArr[intValue].value, byteString)) {
i = i2;
} else if (Util.equal(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 (Util.equal(this.dynamicTable[i5].name, asciiLowercase)) {
if (Util.equal(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) throws IOException {
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();
}
private 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) throws IOException {
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,118 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okio.ByteString;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class Http2 {
static final byte FLAG_ACK = 1;
static final byte FLAG_COMPRESSED = 32;
static final byte FLAG_END_HEADERS = 4;
static final byte FLAG_END_PUSH_PROMISE = 4;
static final byte FLAG_END_STREAM = 1;
static final byte FLAG_NONE = 0;
static final byte FLAG_PADDED = 8;
static final byte FLAG_PRIORITY = 32;
static final int INITIAL_MAX_FRAME_SIZE = 16384;
static final byte TYPE_CONTINUATION = 9;
static final byte TYPE_DATA = 0;
static final byte TYPE_GOAWAY = 7;
static final byte TYPE_HEADERS = 1;
static final byte TYPE_PING = 6;
static final byte TYPE_PRIORITY = 2;
static final byte TYPE_PUSH_PROMISE = 5;
static final byte TYPE_RST_STREAM = 3;
static final byte TYPE_SETTINGS = 4;
static final byte TYPE_WINDOW_UPDATE = 8;
static final ByteString CONNECTION_PREFACE = ByteString.encodeUtf8("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");
private static final String[] FRAME_NAMES = {"DATA", "HEADERS", "PRIORITY", "RST_STREAM", "SETTINGS", "PUSH_PROMISE", "PING", "GOAWAY", "WINDOW_UPDATE", "CONTINUATION"};
static final String[] FLAGS = new String[64];
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++;
}
}
private Http2() {
}
public static IllegalArgumentException illegalArgument(String str, Object... objArr) {
throw new IllegalArgumentException(Util.format(str, objArr));
}
public static IOException ioException(String str, Object... objArr) throws IOException {
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,191 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.mbridge.msdk.thrid.okhttp.Headers;
import com.mbridge.msdk.thrid.okhttp.Interceptor;
import com.mbridge.msdk.thrid.okhttp.OkHttpClient;
import com.mbridge.msdk.thrid.okhttp.Protocol;
import com.mbridge.msdk.thrid.okhttp.Request;
import com.mbridge.msdk.thrid.okhttp.Response;
import com.mbridge.msdk.thrid.okhttp.ResponseBody;
import com.mbridge.msdk.thrid.okhttp.internal.Internal;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okhttp.internal.connection.StreamAllocation;
import com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec;
import com.mbridge.msdk.thrid.okhttp.internal.http.HttpHeaders;
import com.mbridge.msdk.thrid.okhttp.internal.http.RealResponseBody;
import com.mbridge.msdk.thrid.okhttp.internal.http.RequestLine;
import com.mbridge.msdk.thrid.okhttp.internal.http.StatusLine;
import com.mbridge.msdk.thrid.okio.Buffer;
import com.mbridge.msdk.thrid.okio.ByteString;
import com.mbridge.msdk.thrid.okio.ForwardingSource;
import com.mbridge.msdk.thrid.okio.Okio;
import com.mbridge.msdk.thrid.okio.Sink;
import com.mbridge.msdk.thrid.okio.Source;
import com.mbridge.msdk.thrid.okio.Timeout;
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 org.apache.http.protocol.HTTP;
/* loaded from: classes4.dex */
public final class Http2Codec implements HttpCodec {
private final Interceptor.Chain chain;
private final Http2Connection connection;
private final Protocol protocol;
private Http2Stream stream;
final StreamAllocation streamAllocation;
private static final String CONNECTION = "connection";
private static final String HOST = "host";
private static final String KEEP_ALIVE = "keep-alive";
private static final String PROXY_CONNECTION = "proxy-connection";
private static final String TE = "te";
private static final String TRANSFER_ENCODING = "transfer-encoding";
private static final String ENCODING = "encoding";
private static final String UPGRADE = "upgrade";
private static final List<String> HTTP_2_SKIPPED_REQUEST_HEADERS = Util.immutableList(CONNECTION, HOST, KEEP_ALIVE, PROXY_CONNECTION, TE, TRANSFER_ENCODING, ENCODING, UPGRADE, Header.TARGET_METHOD_UTF8, Header.TARGET_PATH_UTF8, Header.TARGET_SCHEME_UTF8, Header.TARGET_AUTHORITY_UTF8);
private static final List<String> HTTP_2_SKIPPED_RESPONSE_HEADERS = Util.immutableList(CONNECTION, HOST, KEEP_ALIVE, PROXY_CONNECTION, TE, TRANSFER_ENCODING, ENCODING, UPGRADE);
public Http2Codec(OkHttpClient okHttpClient, Interceptor.Chain chain, StreamAllocation streamAllocation, Http2Connection http2Connection) {
this.chain = chain;
this.streamAllocation = streamAllocation;
this.connection = http2Connection;
List<Protocol> protocols = okHttpClient.protocols();
Protocol protocol = Protocol.H2_PRIOR_KNOWLEDGE;
this.protocol = protocols.contains(protocol) ? protocol : Protocol.HTTP_2;
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public Sink createRequestBody(Request request, long j) {
return this.stream.getSink();
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public void writeRequestHeaders(Request request) throws IOException {
if (this.stream != null) {
return;
}
Http2Stream newStream = this.connection.newStream(http2HeadersList(request), request.body() != null);
this.stream = newStream;
Timeout readTimeout = newStream.readTimeout();
long readTimeoutMillis = this.chain.readTimeoutMillis();
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
readTimeout.timeout(readTimeoutMillis, timeUnit);
this.stream.writeTimeout().timeout(this.chain.writeTimeoutMillis(), timeUnit);
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public void flushRequest() throws IOException {
this.connection.flush();
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public void finishRequest() throws IOException {
this.stream.getSink().close();
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public Response.Builder readResponseHeaders(boolean z) throws IOException {
Response.Builder readHttp2HeadersList = readHttp2HeadersList(this.stream.takeHeaders(), this.protocol);
if (z && Internal.instance.code(readHttp2HeadersList) == 100) {
return null;
}
return readHttp2HeadersList;
}
public static List<Header> 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++) {
ByteString encodeUtf8 = ByteString.encodeUtf8(headers.name(i).toLowerCase(Locale.US));
if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(encodeUtf8.utf8())) {
arrayList.add(new Header(encodeUtf8, headers.value(i)));
}
}
return arrayList;
}
public static Response.Builder readHttp2HeadersList(Headers headers, Protocol protocol) throws IOException {
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(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 // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public ResponseBody openResponseBody(Response response) throws IOException {
StreamAllocation streamAllocation = this.streamAllocation;
streamAllocation.eventListener.responseBodyStart(streamAllocation.call);
return new RealResponseBody(response.header("Content-Type"), HttpHeaders.contentLength(response), Okio.buffer(new StreamFinishingSource(this.stream.getSource())));
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http.HttpCodec
public void cancel() {
Http2Stream http2Stream = this.stream;
if (http2Stream != null) {
http2Stream.closeLater(ErrorCode.CANCEL);
}
}
public class StreamFinishingSource extends ForwardingSource {
long bytesRead;
boolean completed;
public StreamFinishingSource(Source source) {
super(source);
this.completed = false;
this.bytesRead = 0L;
}
@Override // com.mbridge.msdk.thrid.okio.ForwardingSource, com.mbridge.msdk.thrid.okio.Source
public long read(Buffer buffer, long j) throws IOException {
try {
long read = delegate().read(buffer, j);
if (read > 0) {
this.bytesRead += read;
}
return read;
} catch (IOException e) {
endOfInput(e);
throw e;
}
}
@Override // com.mbridge.msdk.thrid.okio.ForwardingSource, com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
super.close();
endOfInput(null);
}
private void endOfInput(IOException iOException) {
if (this.completed) {
return;
}
this.completed = true;
Http2Codec http2Codec = Http2Codec.this;
http2Codec.streamAllocation.streamFinished(false, http2Codec, this.bytesRead, iOException);
}
}
}

View File

@@ -0,0 +1,366 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okhttp.internal.http2.Hpack;
import com.mbridge.msdk.thrid.okio.Buffer;
import com.mbridge.msdk.thrid.okio.BufferedSource;
import com.mbridge.msdk.thrid.okio.ByteString;
import com.mbridge.msdk.thrid.okio.Source;
import com.mbridge.msdk.thrid.okio.Timeout;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/* loaded from: classes4.dex */
final class Http2Reader implements Closeable {
static final Logger logger = Logger.getLogger(Http2.class.getName());
private final boolean client;
private final ContinuationSource continuation;
final Hpack.Reader hpackReader;
private final BufferedSource source;
public interface Handler {
void ackSettings();
void alternateService(int i, String str, ByteString byteString, String str2, int i2, long j);
void data(boolean z, int i, BufferedSource bufferedSource, int i2) throws IOException;
void goAway(int i, ErrorCode errorCode, ByteString byteString);
void headers(boolean z, int i, int i2, List<Header> 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<Header> list) throws IOException;
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) throws IOException {
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) throws IOException {
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 (IOException unused) {
return false;
}
}
private void readHeaders(Handler handler, int i, byte b, int i2) throws IOException {
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));
}
private List<Header> readHeaderBlock(int i, short s, byte b, int i2) throws IOException {
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();
}
private void readData(Handler handler, int i, byte b, int i2) throws IOException {
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);
}
private void readPriority(Handler handler, int i, byte b, int i2) throws IOException {
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);
}
private void readPriority(Handler handler, int i) throws IOException {
int readInt = this.source.readInt();
handler.priority(i, readInt & Integer.MAX_VALUE, (this.source.readByte() & 255) + 1, (Integer.MIN_VALUE & readInt) != 0);
}
private void readRstStream(Handler handler, int i, byte b, int i2) throws IOException {
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);
}
private void readSettings(Handler handler, int i, byte b, int i2) throws IOException {
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);
}
private void readPushPromise(Handler handler, int i, byte b, int i2) throws IOException {
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));
}
private void readPing(Handler handler, int i, byte b, int i2) throws IOException {
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());
}
private void readGoAway(Handler handler, int i, byte b, int i2) throws IOException {
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);
}
private void readWindowUpdate(Handler handler, int i, byte b, int i2) throws IOException {
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() throws IOException {
this.source.close();
}
public static final class ContinuationSource implements Source {
byte flags;
int left;
int length;
short padding;
private final BufferedSource source;
int streamId;
@Override // com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
}
public ContinuationSource(BufferedSource bufferedSource) {
this.source = bufferedSource;
}
@Override // com.mbridge.msdk.thrid.okio.Source
public long read(Buffer buffer, long j) throws IOException {
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 // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return this.source.timeout();
}
private void readContinuationHeader() throws IOException {
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) throws IOException {
return (bufferedSource.readByte() & 255) | ((bufferedSource.readByte() & 255) << 16) | ((bufferedSource.readByte() & 255) << 8);
}
public static int lengthWithoutPadding(int i, byte b, short s) throws IOException {
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,615 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.mbridge.msdk.thrid.okhttp.Headers;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okhttp.internal.http2.Header;
import com.mbridge.msdk.thrid.okio.AsyncTimeout;
import com.mbridge.msdk.thrid.okio.Buffer;
import com.mbridge.msdk.thrid.okio.BufferedSource;
import com.mbridge.msdk.thrid.okio.Sink;
import com.mbridge.msdk.thrid.okio.Source;
import com.mbridge.msdk.thrid.okio.Timeout;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes4.dex */
public final class Http2Stream {
static final /* synthetic */ boolean $assertionsDisabled = false;
long bytesLeftInWriteWindow;
final Http2Connection connection;
ErrorCode errorCode;
private boolean hasResponseHeaders;
private Header.Listener headersListener;
private final Deque<Headers> headersQueue;
final int id;
final StreamTimeout readTimeout;
final FramingSink sink;
private final FramingSource source;
long unacknowledgedBytesRead = 0;
final StreamTimeout writeTimeout;
public Http2Connection getConnection() {
return this.connection;
}
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();
this.errorCode = null;
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() throws IOException {
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()) {
} else {
throw new StreamResetException(this.errorCode);
}
return this.headersQueue.removeFirst();
}
public synchronized ErrorCode getErrorCode() {
return this.errorCode;
}
public void writeHeaders(List<Header> list, boolean z) throws IOException {
boolean z2;
boolean z3;
boolean z4;
if (list == null) {
throw new NullPointerException("headers == null");
}
synchronized (this) {
z2 = true;
try {
this.hasResponseHeaders = true;
if (z) {
z3 = false;
} else {
this.sink.finished = true;
z3 = true;
}
z4 = z3;
} finally {
}
}
if (!z3) {
synchronized (this.connection) {
if (this.connection.bytesLeftInWriteWindow != 0) {
z2 = false;
}
}
z3 = z2;
}
this.connection.writeSynReply(this.id, z4, list);
if (z3) {
this.connection.flush();
}
}
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) throws IOException {
if (closeInternal(errorCode)) {
this.connection.writeSynReset(this.id, errorCode);
}
}
public void closeLater(ErrorCode errorCode) {
if (closeInternal(errorCode)) {
this.connection.writeSynResetLater(this.id, errorCode);
}
}
private boolean closeInternal(ErrorCode errorCode) {
synchronized (this) {
try {
if (this.errorCode != null) {
return false;
}
if (this.source.finished && this.sink.finished) {
return false;
}
this.errorCode = errorCode;
notifyAll();
this.connection.removeStream(this.id);
return true;
} catch (Throwable th) {
throw th;
}
}
}
public void receiveHeaders(List<Header> list) {
boolean isOpen;
synchronized (this) {
this.hasResponseHeaders = true;
this.headersQueue.add(Util.toHeaders(list));
isOpen = isOpen();
notifyAll();
}
if (isOpen) {
return;
}
this.connection.removeStream(this.id);
}
public void receiveData(BufferedSource bufferedSource, int i) throws IOException {
this.source.receive(bufferedSource, i);
}
public void receiveFin() {
boolean isOpen;
synchronized (this) {
this.source.finished = true;
isOpen = isOpen();
notifyAll();
}
if (isOpen) {
return;
}
this.connection.removeStream(this.id);
}
public synchronized void receiveRstStream(ErrorCode errorCode) {
if (this.errorCode == null) {
this.errorCode = errorCode;
notifyAll();
}
}
public synchronized void setHeadersListener(Header.Listener listener) {
this.headersListener = listener;
if (!this.headersQueue.isEmpty() && listener != null) {
notifyAll();
}
}
public final class FramingSource implements Source {
static final /* synthetic */ boolean $assertionsDisabled = false;
boolean closed;
boolean finished;
private final long maxByteCount;
private final Buffer receiveBuffer = new Buffer();
private final Buffer readBuffer = new Buffer();
public FramingSource(long j) {
this.maxByteCount = j;
}
@Override // com.mbridge.msdk.thrid.okio.Source
public long read(Buffer buffer, long j) throws IOException {
ErrorCode errorCode;
long read;
Headers headers;
Header.Listener listener;
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: " + j);
}
while (true) {
synchronized (Http2Stream.this) {
try {
Http2Stream.this.readTimeout.enter();
try {
Http2Stream http2Stream = Http2Stream.this;
errorCode = http2Stream.errorCode;
if (errorCode == null) {
errorCode = null;
}
if (!this.closed) {
if (!http2Stream.headersQueue.isEmpty() && Http2Stream.this.headersListener != null) {
headers = (Headers) Http2Stream.this.headersQueue.removeFirst();
listener = Http2Stream.this.headersListener;
} else if (this.readBuffer.size() > 0) {
Buffer buffer2 = this.readBuffer;
read = buffer2.read(buffer, Math.min(j, buffer2.size()));
Http2Stream http2Stream2 = Http2Stream.this;
long j2 = http2Stream2.unacknowledgedBytesRead + read;
http2Stream2.unacknowledgedBytesRead = j2;
if (errorCode == null && j2 >= http2Stream2.connection.okHttpSettings.getInitialWindowSize() / 2) {
Http2Stream http2Stream3 = Http2Stream.this;
http2Stream3.connection.writeWindowUpdateLater(http2Stream3.id, http2Stream3.unacknowledgedBytesRead);
Http2Stream.this.unacknowledgedBytesRead = 0L;
}
headers = null;
listener = null;
if (headers == null || listener == null) {
break;
}
listener.onHeaders(headers);
} else if (this.finished || errorCode != null) {
headers = null;
listener = null;
} else {
Http2Stream.this.waitForIo();
Http2Stream.this.readTimeout.exitAndThrowIfTimedOut();
}
read = -1;
if (headers == null) {
break;
}
break;
}
throw new IOException("stream closed");
} finally {
Http2Stream.this.readTimeout.exitAndThrowIfTimedOut();
}
} catch (Throwable th) {
throw th;
}
}
}
if (read != -1) {
updateConnectionFlowControl(read);
return read;
}
if (errorCode == null) {
return -1L;
}
throw new StreamResetException(errorCode);
}
private void updateConnectionFlowControl(long j) {
Http2Stream.this.connection.updateConnectionFlowControl(j);
}
public void receive(BufferedSource bufferedSource, long j) throws IOException {
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 // com.mbridge.msdk.thrid.okio.Source
public Timeout timeout() {
return Http2Stream.this.readTimeout;
}
@Override // com.mbridge.msdk.thrid.okio.Source, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
long size;
ArrayList arrayList;
Header.Listener listener;
synchronized (Http2Stream.this) {
try {
this.closed = true;
size = this.readBuffer.size();
this.readBuffer.clear();
if (Http2Stream.this.headersQueue.isEmpty() || Http2Stream.this.headersListener == null) {
arrayList = null;
listener = null;
} else {
arrayList = new ArrayList(Http2Stream.this.headersQueue);
Http2Stream.this.headersQueue.clear();
listener = Http2Stream.this.headersListener;
}
Http2Stream.this.notifyAll();
} catch (Throwable th) {
throw th;
}
}
if (size > 0) {
updateConnectionFlowControl(size);
}
Http2Stream.this.cancelStreamIfNecessary();
if (listener != null) {
Iterator it = arrayList.iterator();
while (it.hasNext()) {
listener.onHeaders((Headers) it.next());
}
}
}
}
public void cancelStreamIfNecessary() throws IOException {
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);
} else {
if (isOpen) {
return;
}
this.connection.removeStream(this.id);
}
}
public final class FramingSink implements Sink {
static final /* synthetic */ boolean $assertionsDisabled = false;
private static final long EMIT_BUFFER_SIZE = 16384;
boolean closed;
boolean finished;
private final Buffer sendBuffer = new Buffer();
public FramingSink() {
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public void write(Buffer buffer, long j) throws IOException {
this.sendBuffer.write(buffer, j);
while (this.sendBuffer.size() >= 16384) {
emitFrame(false);
}
}
private void emitFrame(boolean z) throws IOException {
Http2Stream http2Stream;
long min;
Http2Stream http2Stream2;
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();
try {
Http2Stream http2Stream3 = Http2Stream.this;
http2Stream3.connection.writeData(http2Stream3.id, z && min == this.sendBuffer.size(), this.sendBuffer, min);
} catch (Throwable th) {
throw th;
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Flushable
public void flush() throws IOException {
synchronized (Http2Stream.this) {
Http2Stream.this.checkOutNotClosed();
}
while (this.sendBuffer.size() > 0) {
emitFrame(false);
Http2Stream.this.connection.flush();
}
}
@Override // com.mbridge.msdk.thrid.okio.Sink
public Timeout timeout() {
return Http2Stream.this.writeTimeout;
}
@Override // com.mbridge.msdk.thrid.okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
synchronized (Http2Stream.this) {
try {
if (this.closed) {
return;
}
if (!Http2Stream.this.sink.finished) {
if (this.sendBuffer.size() > 0) {
while (this.sendBuffer.size() > 0) {
emitFrame(true);
}
} else {
Http2Stream http2Stream = Http2Stream.this;
http2Stream.connection.writeData(http2Stream.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() throws IOException {
FramingSink framingSink = this.sink;
if (framingSink.closed) {
throw new IOException("stream closed");
}
if (framingSink.finished) {
throw new IOException("stream finished");
}
if (this.errorCode != null) {
throw new StreamResetException(this.errorCode);
}
}
public void waitForIo() throws InterruptedIOException {
try {
wait();
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
throw new InterruptedIOException();
}
}
public class StreamTimeout extends AsyncTimeout {
public StreamTimeout() {
}
@Override // com.mbridge.msdk.thrid.okio.AsyncTimeout
public void timedOut() {
Http2Stream.this.closeLater(ErrorCode.CANCEL);
Http2Stream.this.connection.sendDegradedPingLater();
}
@Override // com.mbridge.msdk.thrid.okio.AsyncTimeout
public IOException newTimeoutException(IOException iOException) {
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
if (iOException != null) {
socketTimeoutException.initCause(iOException);
}
return socketTimeoutException;
}
public void exitAndThrowIfTimedOut() throws IOException {
if (exit()) {
throw newTimeoutException(null);
}
}
}
}

View File

@@ -0,0 +1,261 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.mbridge.msdk.thrid.okhttp.internal.Util;
import com.mbridge.msdk.thrid.okhttp.internal.http2.Hpack;
import com.mbridge.msdk.thrid.okio.Buffer;
import com.mbridge.msdk.thrid.okio.BufferedSink;
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;
/* loaded from: classes4.dex */
final class Http2Writer implements Closeable {
private static final Logger logger = Logger.getLogger(Http2.class.getName());
private final boolean client;
private boolean closed;
private final Buffer hpackBuffer;
final Hpack.Writer hpackWriter;
private int maxFrameSize;
private 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() throws IOException {
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) throws IOException {
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<Header> list) throws IOException {
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() throws IOException {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
this.sink.flush();
}
public synchronized void synStream(boolean z, int i, int i2, List<Header> list) throws IOException {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
headers(z, i, list);
}
public synchronized void synReply(boolean z, int i, List<Header> list) throws IOException {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
headers(z, i, list);
}
public synchronized void headers(int i, List<Header> list) throws IOException {
if (this.closed) {
throw new IOException(Consts.PLACEMENT_STATUS_CLOSED);
}
headers(false, i, list);
}
public synchronized void rstStream(int i, ErrorCode errorCode) throws IOException {
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) throws IOException {
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) throws IOException {
frameHeader(i, i2, (byte) 0, b);
if (i2 > 0) {
this.sink.write(buffer, i2);
}
}
public synchronized void settings(Settings settings) throws IOException {
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) throws IOException {
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) throws IOException {
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) throws IOException {
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) throws IOException {
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() throws IOException {
this.closed = true;
this.sink.close();
}
private static void writeMedium(BufferedSink bufferedSink, int i) throws IOException {
bufferedSink.writeByte((i >>> 16) & 255);
bufferedSink.writeByte((i >>> 8) & 255);
bufferedSink.writeByte(i & 255);
}
private void writeContinuationFrames(int i, long j) throws IOException {
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 void headers(boolean z, int i, List<Header> list) throws IOException {
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,137 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import androidx.core.view.PointerIconCompat;
import com.applovin.exoplayer2.common.base.Ascii;
import com.mbridge.msdk.thrid.okio.BufferedSink;
import com.mbridge.msdk.thrid.okio.ByteString;
import com.vungle.ads.internal.signals.SignalKey;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/* loaded from: classes4.dex */
class Huffman {
private 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};
private 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};
private static final Huffman INSTANCE = new Huffman();
private final Node root = new Node();
public static Huffman get() {
return INSTANCE;
}
private Huffman() {
buildTree();
}
public void encode(ByteString byteString, BufferedSink bufferedSink) throws IOException {
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();
}
private void buildTree() {
int i = 0;
while (true) {
byte[] bArr = CODE_LENGTHS;
if (i >= bArr.length) {
return;
}
addCode(i, CODES[i], bArr[i]);
i++;
}
}
private 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 {
final Node[] children;
final int symbol;
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,38 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import com.mbridge.msdk.thrid.okio.BufferedSource;
import java.io.IOException;
import java.util.List;
/* loaded from: classes4.dex */
public interface PushObserver {
public static final PushObserver CANCEL = new PushObserver() { // from class: com.mbridge.msdk.thrid.okhttp.internal.http2.PushObserver.1
@Override // com.mbridge.msdk.thrid.okhttp.internal.http2.PushObserver
public boolean onHeaders(int i, List<Header> list, boolean z) {
return true;
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http2.PushObserver
public boolean onRequest(int i, List<Header> list) {
return true;
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http2.PushObserver
public void onReset(int i, ErrorCode errorCode) {
}
@Override // com.mbridge.msdk.thrid.okhttp.internal.http2.PushObserver
public boolean onData(int i, BufferedSource bufferedSource, int i2, boolean z) throws IOException {
bufferedSource.skip(i2);
return true;
}
};
boolean onData(int i, BufferedSource bufferedSource, int i2, boolean z) throws IOException;
boolean onHeaders(int i, List<Header> list, boolean z);
boolean onRequest(int i, List<Header> list);
void onReset(int i, ErrorCode errorCode);
}

View File

@@ -0,0 +1,90 @@
package com.mbridge.msdk.thrid.okhttp.internal.http2;
import java.util.Arrays;
/* loaded from: classes4.dex */
public final class Settings {
static final int COUNT = 10;
static final int DEFAULT_INITIAL_WINDOW_SIZE = 65535;
static final int ENABLE_PUSH = 2;
static final int HEADER_TABLE_SIZE = 1;
static final int INITIAL_WINDOW_SIZE = 7;
static final int MAX_CONCURRENT_STREAMS = 4;
static final int MAX_FRAME_SIZE = 5;
static final int MAX_HEADER_LIST_SIZE = 6;
private int set;
private 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 boolean getEnablePush(boolean z) {
if ((this.set & 4) != 0) {
if (this.values[2] == 1) {
return true;
}
} else if (z) {
return true;
}
return false;
}
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 getMaxHeaderListSize(int i) {
return (this.set & 64) != 0 ? this.values[6] : i;
}
public int getInitialWindowSize() {
if ((this.set & 128) != 0) {
return this.values[7];
}
return 65535;
}
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 com.mbridge.msdk.thrid.okhttp.internal.http2;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class StreamResetException extends IOException {
public final ErrorCode errorCode;
public StreamResetException(ErrorCode errorCode) {
super("stream was reset: " + errorCode);
this.errorCode = errorCode;
}
}