class Rack::Deflater::GzipStream

Body class used for gzip encoded responses.

def close

Close the original body if possible.
def close
  @body.close if @body.respond_to?(:close)
end

def each(&block)

Yield gzip compressed strings to the given block.
def each(&block)
  @writer = block
  gzip = ::Zlib::GzipWriter.new(self)
  gzip.mtime = @mtime if @mtime
  @body.each { |part|
    # Skip empty strings, as they would result in no output,
    # and flushing empty parts would raise Zlib::BufError.
    next if part.empty?
    gzip.write(part)
    gzip.flush if @sync
  }
ensure
  gzip.close
end

def initialize(body, mtime, sync)

sync :: Whether to flush each gzip chunk as soon as it is ready.
modification time in the gzip header.
mtime :: The modification time of the body, used to set the
body :: Response body to compress with gzip
Initialize the gzip stream. Arguments:
def initialize(body, mtime, sync)
  @body = body
  @mtime = mtime
  @sync = sync
end

def write(data)

Call the block passed to #each with the the gzipped data.
def write(data)
  @writer.call(data)
end