Class: HTTP::Features::AutoDeflate::GzippedBody

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

Defined Under Namespace

Classes: BlockIO

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, #initialize, #size

Constructor Details

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

Instance Method Details

#compress(&block) ⇒ Object



92
93
94
95
96
97
# File 'lib/http/features/auto_deflate.rb', line 92

def compress(&block)
  gzip = Zlib::GzipWriter.new(BlockIO.new(block))
  @body.each { |chunk| gzip.write(chunk) }
ensure
  gzip.finish
end