class Aws::Plugins::RequestCompression::CompressionHandler::GzipIO

@api private

def initialize(body)

def initialize(body)
  @body = body
  @buffer = ChunkBuffer.new
  @gzip_writer = Zlib::GzipWriter.new(@buffer)
end

def read(length, buff = nil)

def read(length, buff = nil)
  if @gzip_writer.closed?
    # an empty string to signify an end as
    # there will be nothing remaining to be read
    StringIO.new('').read(length, buff)
    return
  end
  chunk = @body.read(length)
  if !chunk || chunk.empty?
    # closing the writer will write one last chunk
    # with a trailer (to be read from the @buffer)
    @gzip_writer.close
  else
    # flush happens first to ensure that header fields
    # are being sent over since write will override
    @gzip_writer.flush
    @gzip_writer.write(chunk)
  end
  StringIO.new(@buffer.last_chunk).read(length, buff)
end