110 lines
3.4 KiB
Java
110 lines
3.4 KiB
Java
package io.grpc.okhttp;
|
|
|
|
import com.google.common.primitives.UnsignedBytes;
|
|
import io.grpc.internal.AbstractReadableBuffer;
|
|
import io.grpc.internal.ReadableBuffer;
|
|
import java.io.EOFException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.nio.ByteBuffer;
|
|
import o.C14957gcv;
|
|
import o.C15111ghZ;
|
|
import o.C15169gix;
|
|
import o.C15170giy;
|
|
import o.giE;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes6.dex */
|
|
public class OkHttpReadableBuffer extends AbstractReadableBuffer {
|
|
private final C15111ghZ buffer;
|
|
|
|
private void fakeEofExceptionMethod() throws EOFException {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public OkHttpReadableBuffer(C15111ghZ c15111ghZ) {
|
|
this.buffer = c15111ghZ;
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public int readUnsignedByte() {
|
|
try {
|
|
fakeEofExceptionMethod();
|
|
return this.buffer.f() & UnsignedBytes.MAX_VALUE;
|
|
} catch (EOFException e) {
|
|
throw new IndexOutOfBoundsException(e.getMessage());
|
|
}
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public void skipBytes(int i) {
|
|
try {
|
|
this.buffer.j(i);
|
|
} catch (EOFException e) {
|
|
throw new IndexOutOfBoundsException(e.getMessage());
|
|
}
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public void readBytes(byte[] bArr, int i, int i2) {
|
|
while (i2 > 0) {
|
|
int c = this.buffer.c(bArr, i, i2);
|
|
if (c == -1) {
|
|
StringBuilder sb = new StringBuilder("EOF trying to read ");
|
|
sb.append(i2);
|
|
sb.append(" bytes");
|
|
throw new IndexOutOfBoundsException(sb.toString());
|
|
}
|
|
i2 -= c;
|
|
i += c;
|
|
}
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public void readBytes(ByteBuffer byteBuffer) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public void readBytes(OutputStream outputStream, int i) throws IOException {
|
|
C15111ghZ c15111ghZ = this.buffer;
|
|
long j = i;
|
|
C14957gcv.e(outputStream, "");
|
|
giE.d(c15111ghZ.c, 0L, j);
|
|
C15170giy c15170giy = c15111ghZ.d;
|
|
while (j > 0) {
|
|
C14957gcv.e(c15170giy);
|
|
int min = (int) Math.min(j, c15170giy.d - c15170giy.e);
|
|
outputStream.write(c15170giy.c, c15170giy.e, min);
|
|
c15170giy.e += min;
|
|
long j2 = min;
|
|
c15111ghZ.c -= j2;
|
|
j -= j2;
|
|
if (c15170giy.e == c15170giy.d) {
|
|
C15170giy d = c15170giy.d();
|
|
c15111ghZ.d = d;
|
|
C15169gix.e(c15170giy);
|
|
c15170giy = d;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public ReadableBuffer readBytes(int i) {
|
|
C15111ghZ c15111ghZ = new C15111ghZ();
|
|
c15111ghZ.write(this.buffer, i);
|
|
return new OkHttpReadableBuffer(c15111ghZ);
|
|
}
|
|
|
|
@Override // io.grpc.internal.AbstractReadableBuffer, io.grpc.internal.ReadableBuffer, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() {
|
|
C15111ghZ c15111ghZ = this.buffer;
|
|
c15111ghZ.j(c15111ghZ.c);
|
|
}
|
|
|
|
@Override // io.grpc.internal.ReadableBuffer
|
|
public int readableBytes() {
|
|
return (int) this.buffer.c;
|
|
}
|
|
}
|