package okhttp3.internal.ws; import java.io.Closeable; import java.io.IOException; import java.util.zip.Inflater; import o.C14957gcv; import o.C15111ghZ; import o.C15158gim; import o.giD; /* loaded from: classes6.dex */ public final class MessageInflater implements Closeable { private final C15111ghZ deflatedBytes; private final Inflater inflater; private final C15158gim inflaterSource; private final boolean noContextTakeover; public MessageInflater(boolean z) { this.noContextTakeover = z; C15111ghZ c15111ghZ = new C15111ghZ(); this.deflatedBytes = c15111ghZ; Inflater inflater = new Inflater(true); this.inflater = inflater; this.inflaterSource = new C15158gim((giD) c15111ghZ, inflater); } @Override // java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { this.inflaterSource.close(); } public final void inflate(C15111ghZ c15111ghZ) throws IOException { C14957gcv.e(c15111ghZ, ""); if (this.deflatedBytes.c == 0) { if (this.noContextTakeover) { this.inflater.reset(); } this.deflatedBytes.c((giD) c15111ghZ); this.deflatedBytes.j(65535); long bytesRead = this.inflater.getBytesRead(); long j = this.deflatedBytes.c; do { this.inflaterSource.d(c15111ghZ, Long.MAX_VALUE); } while (this.inflater.getBytesRead() < bytesRead + j); return; } throw new IllegalArgumentException("Failed requirement.".toString()); } }