Class: HTTP::Features::AutoDeflate::DeflatedBody

Inherits:
CompressedBody show all
Defined in:
lib/http/features/auto_deflate.rb

Overview

Deflate-compressed request body wrapper

Instance Attribute Summary

Attributes inherited from Request::Body

#source

Instance Method Summary collapse

Methods inherited from CompressedBody

#each, #initialize, #size

Methods inherited from Request::Body

#==, #each, #empty?, #initialize, #loggable?, #size

Constructor Details

This class inherits a constructor from HTTP::Features::AutoDeflate::CompressedBody

Instance Method Details

#compressnil

Compresses data using deflate

Examples:

deflated_body.compress { |data| io.write(data) }

Returns:

  • (nil)


218
219
220
221
222
223
224
225
226
# File 'lib/http/features/auto_deflate.rb', line 218

def compress
  deflater = Zlib::Deflate.new

  @body.each { |chunk| yield deflater.deflate(chunk) }

  yield deflater.finish
ensure
  deflater.close
end