Class: Aws::Plugins::RequestCompression::CompressionHandler::GzipIO Private
- Inherits:
-
Object
- Object
- Aws::Plugins::RequestCompression::CompressionHandler::GzipIO
- Defined in:
- lib/aws-sdk-core/plugins/request_compression.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(body) ⇒ GzipIO
constructor
private
A new instance of GzipIO.
- #read(length, buff = nil) ⇒ Object private
Constructor Details
#initialize(body) ⇒ GzipIO
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GzipIO.
180 181 182 183 184 |
# 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 |
Instance Method Details
#read(length, buff = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# 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 |