private void consumeTrailer() throws IOException { // Read the eight-byte trailer. Confirm the body's CRC and size. // +---+---+---+---+---+---+---+---+ // | CRC32 | ISIZE | // +---+---+---+---+---+---+---+---+ checkEqual("CRC", source.readIntLe(), (int) crc.getValue()); checkEqual("ISIZE", source.readIntLe(), (int) inflater.getBytesWritten()); }
if (isize != (inf.getBytesWritten() & 0xffffffffL)) { throw new IOException("Gzip-compressed data is corrupt" + "(uncompressed size mismatch)");
if (inputSize != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException( "stored gzip size doesn't match decompressed size");
/** * Moved from i2ptunnel HTTPResponseOutputStream.InternalGZIPInputStream * @since 0.8.9 */ public long getTotalExpanded() { try { return inf.getBytesWritten(); } catch (RuntimeException e) { // possible NPE in some implementations return 0; } }
/** * Inflater statistic */ public long getTotalExpanded() { try { return inf.getBytesWritten(); } catch (RuntimeException e) { // possible NPE in some implementations return 0; } }
public long getBytesWritten() { if (inf != null) { return this.inf.getBytesWritten(); } return 0; } }
public long getBytesWritten() { if (inf != null) { return this.inf.getBytesWritten(); } return 0; } }
public long getUncompressedBytesRead() { return inflater.getBytesWritten(); } public long getCompressedBytesRead() {
public long getUncompressedBytesRead() { return inflater.getBytesWritten(); } public long getCompressedBytesRead() {
public long getUncompressedBytesRead() { return inflater.getBytesWritten(); } public long getCompressedBytesRead() {
public int available() throws IOException { if (closeRequested) return 0; long avail = zfin.size() - inf.getBytesWritten(); return (avail > (long) Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) avail); }
private void readTrailer(byte[] bytes) throws IOException { InputStream in = new ByteArrayInputStream(bytes); // Uses left-to-right evaluation order long intIn = readUInt(in); long len = readUInt(in); Checksum checksum = this.checkedOutStream.getChecksum(); if ((checksum != null) && (intIn != checksum.getValue())) { throw new IOException("Corrupt GZIP trailer (bad CRC value)"); } if (len != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException("Corrupt GZIP trailer (bad bytes-written size)"); } }
private void readTrailer(byte[] bytes) throws IOException { InputStream in = new ByteArrayInputStream(bytes); // Uses left-to-right evaluation order long intIn = readUInt(in); long len = readUInt(in); Checksum checksum = this.checkedOutStream.getChecksum(); if ((checksum != null) && (intIn != checksum.getValue())) { throw new IOException("Corrupt GZIP trailer (bad CRC value)"); } if (len != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException("Corrupt GZIP trailer (bad bytes-written size)"); } }
private static String toDetail(Inflater inflater) { return String.format("Inflater[finished=%b,read=%d,written=%d,remaining=%d,in=%d,out=%d]",inflater.finished(),inflater.getBytesRead(), inflater.getBytesWritten(),inflater.getRemaining(),inflater.getTotalIn(),inflater.getTotalOut()); }
private static String toDetail(Inflater inflater) { return String.format("Inflater[finished=%b,read=%d,written=%d,remaining=%d,in=%d,out=%d]", inflater.finished(), inflater.getBytesRead(), inflater.getBytesWritten(), inflater.getRemaining(), inflater.getTotalIn(), inflater.getTotalOut()); }
private static String toDetail(Inflater inflater) { return String.format("Inflater[finished=%b,read=%d,written=%d,remaining=%d,in=%d,out=%d]", inflater.finished(), inflater.getBytesRead(), inflater.getBytesWritten(), inflater.getRemaining(), inflater.getTotalIn(), inflater.getTotalOut()); }
private void consumeTrailer() throws IOException { // Read the eight-byte trailer. Confirm the body's CRC and size. // +---+---+---+---+---+---+---+---+ // | CRC32 | ISIZE | // +---+---+---+---+---+---+---+---+ checkEqual("CRC", source.readIntLe(), (int) crc.getValue()); checkEqual("ISIZE", source.readIntLe(), (int) inflater.getBytesWritten()); }
private void consumeTrailer() throws IOException { // Read the eight-byte trailer. Confirm the body's CRC and size. // +---+---+---+---+---+---+---+---+ // | CRC32 | ISIZE | // +---+---+---+---+---+---+---+---+ checkEqual("CRC", source.readIntLe(), (int) crc.getValue()); checkEqual("ISIZE", source.readIntLe(), (int) inflater.getBytesWritten()); }
private void consumeTrailer() throws IOException { // Read the eight-byte trailer. Confirm the body's CRC and size. // +---+---+---+---+---+---+---+---+ // | CRC32 | ISIZE | // +---+---+---+---+---+---+---+---+ checkEqual("CRC", source.readIntLe(), (int) crc.getValue()); checkEqual("ISIZE", source.readIntLe(), (int) inflater.getBytesWritten()); }
private void checkTrailer(ByteBuffer in) throws DataFormatException { GZipHeader.Trailer trailer = GZipHeader.readGZipTrailer(in); if (trailer.getLength() != inflater.getBytesWritten()) { throw new DataFormatException("GZip length does not match"); } if (trailer.getChecksum() != checksum.getValue()) { throw new DataFormatException("GZip checksum does not match"); } }