769 lines
29 KiB
Java
769 lines
29 KiB
Java
package okhttp3.repackaged.internal.framed;
|
|
|
|
import com.airbnb.deeplinkdispatch.base.MatchIndex;
|
|
import com.google.common.primitives.UnsignedBytes;
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import o.C15183gjd;
|
|
import o.InterfaceC15142giR;
|
|
import o.giM;
|
|
import o.giO;
|
|
import o.giP;
|
|
import o.giY;
|
|
import o.giZ;
|
|
import okhttp3.repackaged.Protocol;
|
|
import okhttp3.repackaged.internal.framed.FrameReader;
|
|
import okhttp3.repackaged.internal.framed.a;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class Http2 implements Variant {
|
|
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;
|
|
private static final Logger logger = Logger.getLogger(b.class.getName());
|
|
private static final giP akw = giP.b("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.Variant
|
|
public final Protocol getProtocol() {
|
|
return Protocol.HTTP_2;
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.Variant
|
|
public final FrameReader newReader(InterfaceC15142giR interfaceC15142giR, boolean z) {
|
|
return new c(interfaceC15142giR, 4096, z);
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.Variant
|
|
public final FrameWriter newWriter(giO gio, boolean z) {
|
|
return new d(gio, z);
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class c implements FrameReader {
|
|
private final a akx;
|
|
final a.C0130a aky;
|
|
private final boolean client;
|
|
private final InterfaceC15142giR source;
|
|
|
|
c(InterfaceC15142giR interfaceC15142giR, int i, boolean z) {
|
|
this.source = interfaceC15142giR;
|
|
this.client = z;
|
|
a aVar = new a(interfaceC15142giR);
|
|
this.akx = aVar;
|
|
this.aky = new a.C0130a(i, aVar);
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameReader
|
|
public final void readConnectionPreface() throws IOException {
|
|
if (this.client) {
|
|
return;
|
|
}
|
|
giP e = this.source.e(Http2.akw.d.length);
|
|
if (Http2.logger.isLoggable(Level.FINE)) {
|
|
Http2.logger.fine(String.format("<< CONNECTION %s", e.b()));
|
|
}
|
|
if (Http2.akw.equals(e)) {
|
|
return;
|
|
}
|
|
String str = e.c;
|
|
if (str == null) {
|
|
str = new String(e.d, C15183gjd.e);
|
|
e.c = str;
|
|
}
|
|
throw Http2.ioException("Expected a connection header but was %s", str);
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameReader
|
|
public final boolean nextFrame(FrameReader.Handler handler) throws IOException {
|
|
try {
|
|
this.source.j(9L);
|
|
int d = Http2.d(this.source);
|
|
if (d < 0 || d > 16384) {
|
|
throw Http2.ioException("FRAME_SIZE_ERROR: %s", Integer.valueOf(d));
|
|
}
|
|
byte i = this.source.i();
|
|
byte i2 = this.source.i();
|
|
int k = this.source.k() & Integer.MAX_VALUE;
|
|
if (Http2.logger.isLoggable(Level.FINE)) {
|
|
Http2.logger.fine(b.a(true, k, d, i, i2));
|
|
}
|
|
switch (i) {
|
|
case 0:
|
|
b(handler, d, i2, k);
|
|
return true;
|
|
case 1:
|
|
a(handler, d, i2, k);
|
|
return true;
|
|
case 2:
|
|
c(handler, d, i2, k);
|
|
return true;
|
|
case 3:
|
|
d(handler, d, i2, k);
|
|
return true;
|
|
case 4:
|
|
e(handler, d, i2, k);
|
|
return true;
|
|
case 5:
|
|
f(handler, d, i2, k);
|
|
return true;
|
|
case 6:
|
|
g(handler, d, i2, k);
|
|
return true;
|
|
case 7:
|
|
h(handler, d, i2, k);
|
|
return true;
|
|
case 8:
|
|
i(handler, d, i2, k);
|
|
return true;
|
|
default:
|
|
this.source.f(d);
|
|
return true;
|
|
}
|
|
} catch (IOException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void a(FrameReader.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 i3 = (b & 8) != 0 ? (short) (this.source.i() & UnsignedBytes.MAX_VALUE) : (short) 0;
|
|
if ((b & 32) != 0) {
|
|
a(handler, i2);
|
|
i -= 5;
|
|
}
|
|
handler.headers(false, z, i2, -1, a(Http2.lengthWithoutPadding(i, b, i3), i3, b, i2), HeadersMode.HTTP_20_HEADERS);
|
|
}
|
|
|
|
private List<Header> a(int i, short s, byte b, int i2) throws IOException {
|
|
a aVar = this.akx;
|
|
aVar.left = i;
|
|
aVar.length = i;
|
|
this.akx.padding = s;
|
|
this.akx.flags = b;
|
|
this.akx.streamId = i2;
|
|
this.aky.readHeaders();
|
|
return this.aky.getAndResetHeaderList();
|
|
}
|
|
|
|
private void b(FrameReader.Handler handler, int i, byte b, int i2) throws IOException {
|
|
boolean z = (b & 1) != 0;
|
|
if ((b & 32) != 0) {
|
|
throw Http2.ioException("PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA", new Object[0]);
|
|
}
|
|
short i3 = (b & 8) != 0 ? (short) (this.source.i() & UnsignedBytes.MAX_VALUE) : (short) 0;
|
|
handler.data(z, i2, this.source, Http2.lengthWithoutPadding(i, b, i3));
|
|
this.source.f(i3);
|
|
}
|
|
|
|
private void c(FrameReader.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]);
|
|
}
|
|
a(handler, i2);
|
|
}
|
|
|
|
private void a(FrameReader.Handler handler, int i) throws IOException {
|
|
int k = this.source.k();
|
|
handler.priority(i, k & Integer.MAX_VALUE, (this.source.i() & UnsignedBytes.MAX_VALUE) + 1, (Integer.MIN_VALUE & k) != 0);
|
|
}
|
|
|
|
private void d(FrameReader.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 k = this.source.k();
|
|
ErrorCode fromHttp2 = ErrorCode.fromHttp2(k);
|
|
if (fromHttp2 == null) {
|
|
throw Http2.ioException("TYPE_RST_STREAM unexpected error code: %d", Integer.valueOf(k));
|
|
}
|
|
handler.rstStream(i2, fromHttp2);
|
|
}
|
|
|
|
private void e(FrameReader.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) {
|
|
short o2 = this.source.o();
|
|
int k = this.source.k();
|
|
if (o2 != 2) {
|
|
if (o2 == 3) {
|
|
o2 = 4;
|
|
} else if (o2 == 4) {
|
|
if (k < 0) {
|
|
throw Http2.ioException("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1", new Object[0]);
|
|
}
|
|
o2 = 7;
|
|
} else if (o2 == 5 && (k < 16384 || k > 16777215)) {
|
|
throw Http2.ioException("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: %s", Integer.valueOf(k));
|
|
}
|
|
} else if (k != 0 && k != 1) {
|
|
throw Http2.ioException("PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1", new Object[0]);
|
|
}
|
|
settings.d(o2, 0, k);
|
|
}
|
|
handler.settings(false, settings);
|
|
if (settings.getHeaderTableSize() >= 0) {
|
|
this.aky.x(settings.getHeaderTableSize());
|
|
}
|
|
}
|
|
|
|
private void f(FrameReader.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 i3 = (b & 8) != 0 ? (short) (this.source.i() & UnsignedBytes.MAX_VALUE) : (short) 0;
|
|
handler.pushPromise(i2, Integer.MAX_VALUE & this.source.k(), a(Http2.lengthWithoutPadding(i - 4, b, i3), i3, b, i2));
|
|
}
|
|
|
|
private void g(FrameReader.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.k(), this.source.k());
|
|
}
|
|
|
|
private void h(FrameReader.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 k = this.source.k();
|
|
int k2 = this.source.k();
|
|
int i3 = i - 8;
|
|
ErrorCode fromHttp2 = ErrorCode.fromHttp2(k2);
|
|
if (fromHttp2 == null) {
|
|
throw Http2.ioException("TYPE_GOAWAY unexpected error code: %d", Integer.valueOf(k2));
|
|
}
|
|
giP gip = giP.a;
|
|
if (i3 > 0) {
|
|
gip = this.source.e(i3);
|
|
}
|
|
handler.goAway(k, fromHttp2, gip);
|
|
}
|
|
|
|
private void i(FrameReader.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 k = this.source.k() & 2147483647L;
|
|
if (k == 0) {
|
|
throw Http2.ioException("windowSizeIncrement was 0", Long.valueOf(k));
|
|
}
|
|
handler.windowUpdate(i2, k);
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
this.source.close();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class d implements FrameWriter {
|
|
private final a.b akA;
|
|
private int akB;
|
|
private final giM akz;
|
|
private final boolean client;
|
|
private boolean closed;
|
|
private final giO sink;
|
|
|
|
d(giO gio, boolean z) {
|
|
this.sink = gio;
|
|
this.client = z;
|
|
giM gim = new giM();
|
|
this.akz = gim;
|
|
this.akA = new a.b(gim);
|
|
this.akB = 16384;
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void flush() throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void ackSettings(Settings settings) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
this.akB = settings.getMaxFrameSize(this.akB);
|
|
frameHeader(0, 0, (byte) 4, (byte) 1);
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void connectionPreface() throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
if (this.client) {
|
|
if (Http2.logger.isLoggable(Level.FINE)) {
|
|
Http2.logger.fine(String.format(">> CONNECTION %s", Http2.akw.b()));
|
|
}
|
|
this.sink.a(Http2.akw.e());
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void synStream(boolean z, boolean z2, int i, int i2, List<Header> list) throws IOException {
|
|
synchronized (this) {
|
|
if (z2) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
headers(z, i, list);
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void synReply(boolean z, int i, List<Header> list) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
headers(z, i, list);
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void headers(int i, List<Header> list) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
headers(false, i, list);
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void pushPromise(int i, int i2, List<Header> list) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
this.akA.writeHeaders(list);
|
|
long j = this.akz.a;
|
|
int min = (int) Math.min(this.akB - 4, j);
|
|
long j2 = min;
|
|
frameHeader(i, min + 4, (byte) 5, j == j2 ? (byte) 4 : (byte) 0);
|
|
this.sink.d(i2 & Integer.MAX_VALUE);
|
|
this.sink.write(this.akz, j2);
|
|
if (j > j2) {
|
|
a(i, j - j2);
|
|
}
|
|
}
|
|
}
|
|
|
|
final void headers(boolean z, int i, List<Header> list) throws IOException {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
this.akA.writeHeaders(list);
|
|
long j = this.akz.a;
|
|
int min = (int) Math.min(this.akB, j);
|
|
long j2 = min;
|
|
byte b = j == j2 ? (byte) 4 : (byte) 0;
|
|
if (z) {
|
|
b = (byte) (b | 1);
|
|
}
|
|
frameHeader(i, min, (byte) 1, b);
|
|
this.sink.write(this.akz, j2);
|
|
if (j > j2) {
|
|
a(i, j - j2);
|
|
}
|
|
}
|
|
|
|
private void a(int i, long j) throws IOException {
|
|
while (j > 0) {
|
|
int min = (int) Math.min(this.akB, j);
|
|
long j2 = min;
|
|
j -= j2;
|
|
frameHeader(i, min, (byte) 9, j == 0 ? (byte) 4 : (byte) 0);
|
|
this.sink.write(this.akz, j2);
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void rstStream(int i, ErrorCode errorCode) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
if (errorCode.httpCode == -1) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
frameHeader(i, 4, (byte) 3, (byte) 0);
|
|
this.sink.d(errorCode.httpCode);
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void data(boolean z, int i, giM gim, int i2) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
a(i, z ? (byte) 1 : (byte) 0, gim, i2);
|
|
}
|
|
}
|
|
|
|
final void a(int i, byte b, giM gim, int i2) throws IOException {
|
|
frameHeader(i, i2, (byte) 0, b);
|
|
if (i2 > 0) {
|
|
this.sink.write(gim, i2);
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void settings(Settings settings) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
int i = 0;
|
|
frameHeader(0, settings.size() * 6, (byte) 4, (byte) 0);
|
|
while (i < 10) {
|
|
if (settings.isSet(i)) {
|
|
this.sink.g(i == 4 ? 3 : i == 7 ? 4 : i);
|
|
this.sink.d(settings.get(i));
|
|
}
|
|
i++;
|
|
}
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void ping(boolean z, int i, int i2) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("closed");
|
|
}
|
|
frameHeader(0, 8, (byte) 6, z ? (byte) 1 : (byte) 0);
|
|
this.sink.d(i);
|
|
this.sink.d(i2);
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void goAway(int i, ErrorCode errorCode, byte[] bArr) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("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.d(i);
|
|
this.sink.d(errorCode.httpCode);
|
|
if (bArr.length > 0) {
|
|
this.sink.a(bArr);
|
|
}
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final void windowUpdate(int i, long j) throws IOException {
|
|
synchronized (this) {
|
|
if (this.closed) {
|
|
throw new IOException("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.d((int) j);
|
|
this.sink.flush();
|
|
}
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
synchronized (this) {
|
|
this.closed = true;
|
|
this.sink.close();
|
|
}
|
|
}
|
|
|
|
final void frameHeader(int i, int i2, byte b, byte b2) throws IOException {
|
|
if (Http2.logger.isLoggable(Level.FINE)) {
|
|
Http2.logger.fine(b.a(false, i, i2, b, b2));
|
|
}
|
|
int i3 = this.akB;
|
|
if (i2 > i3) {
|
|
throw Http2.illegalArgument("FRAME_SIZE_ERROR length > %d: %d", Integer.valueOf(i3), Integer.valueOf(i2));
|
|
}
|
|
if ((Integer.MIN_VALUE & i) == 0) {
|
|
Http2.a(this.sink, i2);
|
|
this.sink.b(b & UnsignedBytes.MAX_VALUE);
|
|
this.sink.b(b2 & UnsignedBytes.MAX_VALUE);
|
|
this.sink.d(i & Integer.MAX_VALUE);
|
|
return;
|
|
}
|
|
throw Http2.illegalArgument("reserved bit set: %s", Integer.valueOf(i));
|
|
}
|
|
|
|
@Override // okhttp3.repackaged.internal.framed.FrameWriter
|
|
public final int maxDataLength() {
|
|
return this.akB;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static IllegalArgumentException illegalArgument(String str, Object... objArr) {
|
|
throw new IllegalArgumentException(String.format(str, objArr));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static IOException ioException(String str, Object... objArr) throws IOException {
|
|
throw new IOException(String.format(str, objArr));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes6.dex */
|
|
public static final class a implements giZ {
|
|
byte flags;
|
|
int left;
|
|
int length;
|
|
short padding;
|
|
private final InterfaceC15142giR source;
|
|
int streamId;
|
|
|
|
@Override // o.giZ, java.io.Closeable, java.lang.AutoCloseable
|
|
public final void close() throws IOException {
|
|
}
|
|
|
|
public a(InterfaceC15142giR interfaceC15142giR) {
|
|
this.source = interfaceC15142giR;
|
|
}
|
|
|
|
@Override // o.giZ
|
|
public final long read(giM gim, long j) throws IOException {
|
|
while (true) {
|
|
int i = this.left;
|
|
if (i == 0) {
|
|
this.source.f(this.padding);
|
|
this.padding = (short) 0;
|
|
if ((this.flags & 4) != 0) {
|
|
return -1L;
|
|
}
|
|
uN();
|
|
} else {
|
|
long read = this.source.read(gim, Math.min(j, i));
|
|
if (read == -1) {
|
|
return -1L;
|
|
}
|
|
this.left = (int) (this.left - read);
|
|
return read;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // o.giZ
|
|
public final giY timeout() {
|
|
return this.source.timeout();
|
|
}
|
|
|
|
private void uN() throws IOException {
|
|
int i = this.streamId;
|
|
int d = Http2.d(this.source);
|
|
this.left = d;
|
|
this.length = d;
|
|
byte i2 = this.source.i();
|
|
this.flags = this.source.i();
|
|
if (Http2.logger.isLoggable(Level.FINE)) {
|
|
Http2.logger.fine(b.a(true, this.streamId, this.length, i2, this.flags));
|
|
}
|
|
int k = this.source.k() & Integer.MAX_VALUE;
|
|
this.streamId = k;
|
|
if (i2 != 9) {
|
|
throw Http2.ioException("%s != TYPE_CONTINUATION", Byte.valueOf(i2));
|
|
}
|
|
if (k != i) {
|
|
throw Http2.ioException("TYPE_CONTINUATION streamId changed", new Object[0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int lengthWithoutPadding(int i, byte b2, short s) throws IOException {
|
|
if ((b2 & 8) != 0) {
|
|
i--;
|
|
}
|
|
if (s <= i) {
|
|
return (short) (i - s);
|
|
}
|
|
throw ioException("PROTOCOL_ERROR padding %s > remaining length %s", Short.valueOf(s), Integer.valueOf(i));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes6.dex */
|
|
public static final class b {
|
|
private static final String[] TYPES = {"DATA", "HEADERS", "PRIORITY", "RST_STREAM", "SETTINGS", "PUSH_PROMISE", "PING", "GOAWAY", "WINDOW_UPDATE", "CONTINUATION"};
|
|
private static final String[] FLAGS = new String[64];
|
|
private static final String[] BINARY = new String[256];
|
|
|
|
b() {
|
|
}
|
|
|
|
static String a(boolean z, int i, int i2, byte b, byte b2) {
|
|
String[] strArr = TYPES;
|
|
String format = b < strArr.length ? strArr[b] : String.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 String.format("%s 0x%08x %5d %-13s %s", objArr);
|
|
}
|
|
|
|
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];
|
|
}
|
|
|
|
static {
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (true) {
|
|
String[] strArr = BINARY;
|
|
if (i2 >= strArr.length) {
|
|
break;
|
|
}
|
|
strArr[i2] = String.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];
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(strArr2[i3]);
|
|
sb.append("|PADDED");
|
|
strArr2[i3 | 8] = sb.toString();
|
|
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;
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append(strArr3[i6]);
|
|
sb2.append(MatchIndex.ALLOWED_VALUES_SEPARATOR);
|
|
sb2.append(strArr3[i5]);
|
|
strArr3[i7] = sb2.toString();
|
|
StringBuilder sb3 = new StringBuilder();
|
|
sb3.append(strArr3[i6]);
|
|
sb3.append(MatchIndex.ALLOWED_VALUES_SEPARATOR);
|
|
sb3.append(strArr3[i5]);
|
|
sb3.append("|PADDED");
|
|
strArr3[i7 | 8] = sb3.toString();
|
|
}
|
|
while (true) {
|
|
String[] strArr4 = FLAGS;
|
|
if (i >= strArr4.length) {
|
|
return;
|
|
}
|
|
if (strArr4[i] == null) {
|
|
strArr4[i] = BINARY[i];
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int d(InterfaceC15142giR interfaceC15142giR) throws IOException {
|
|
return (interfaceC15142giR.i() & UnsignedBytes.MAX_VALUE) | ((interfaceC15142giR.i() & UnsignedBytes.MAX_VALUE) << 16) | ((interfaceC15142giR.i() & UnsignedBytes.MAX_VALUE) << 8);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static void a(giO gio, int i) throws IOException {
|
|
gio.b((i >>> 16) & 255);
|
|
gio.b((i >>> 8) & 255);
|
|
gio.b(i & 255);
|
|
}
|
|
}
|