class Aws::Plugins::RequestCompression::CompressionHandler::GzipIO
@api private
Public Class Methods
Source
# File lib/aws-sdk-core/plugins/request_compression.rb, line 180 def initialize(body) @body = body @buffer = ChunkBuffer.new @gzip_writer = Zlib::GzipWriter.new(@buffer) end
Public Instance Methods
Source
# File lib/aws-sdk-core/plugins/request_compression.rb, line 186 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