def read(length = nil)
      data = @buffer

      while chunk = @io.read(CHUNK) do
        inflated = @zstream.inflate(chunk)
        @crc = Zlib.crc32 inflated, @crc
        data << inflated

        break if length and data.length > length
      end

      if length then
        @buffer = data.slice! length..-1
      else
        @buffer = ''
      end

      check_footer if @zstream.finished? and not footer_finished?

      data
    rescue Zlib::Error => e
      raise GzipFile::Error, e.message
    end
def read(length = nil)
      data = @buffer

      while chunk = @io.read(CHUNK) do
        inflated = @zstream.inflate(chunk)
        @crc = Zlib.crc32 inflated, @crc
        data << inflated

        break if length and data.length > length
      end

      if length then
        @buffer = data.slice! length..-1
      else
        @buffer = ''
      end

      check_footer if @zstream.finished? and not footer_finished?

      data
    rescue Zlib::Error => e
      raise GzipFile::Error, e.message
    end
See Zlib::GzipReader documentation for a description.