def check_footer
      @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED

      footer = @zstream.input.slice! 0, 8
      rest = @io.read 8 - footer.length
      footer << rest if rest

      raise NoFooter, 'footer is not found' unless footer.length == 8

      crc, length = footer.unpack 'VV'

      @zstream[:total_in] += 8 # to rewind correctly

      raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc

      raise LengthError, 'invalid compressed data -- length error' unless
        length == @zstream.total_out
    end
def check_footer
      @zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED

      footer = @zstream.input.slice! 0, 8
      rest = @io.read 8 - footer.length
      footer << rest if rest

      raise NoFooter, 'footer is not found' unless footer.length == 8

      crc, length = footer.unpack 'VV'

      @zstream[:total_in] += 8 # to rewind correctly

      raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc

      raise LengthError, 'invalid compressed data -- length error' unless
        length == @zstream.total_out
    end
HACK use a buffer class

 Creates a GzipReader object associated with +io+. The GzipReader object
 reads gzipped data from +io+, and parses/decompresses them.  At least,
 +io+ must have a +read+ method that behaves same as the +read+ method in
 IO class.

 If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
 exception.