Class: Rack::Deflater::DeflateStream
- Inherits:
-
Object
- Object
- Rack::Deflater::DeflateStream
- Defined in:
- lib/rack/deflater.rb
Constant Summary collapse
- DEFLATE_ARGS =
[ Zlib::DEFAULT_COMPRESSION, # drop the zlib header which causes both Safari and IE to choke -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY ]
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(body) ⇒ DeflateStream
constructor
A new instance of DeflateStream.
Constructor Details
#initialize(body) ⇒ DeflateStream
Returns a new instance of DeflateStream.
101 102 103 |
# File 'lib/rack/deflater.rb', line 101 def initialize(body) @body = body end |
Instance Method Details
#each ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/rack/deflater.rb', line 105 def each deflater = ::Zlib::Deflate.new(*DEFLATE_ARGS) @body.each { |part| yield deflater.deflate(part, Zlib::SYNC_FLUSH) } yield deflater.finish nil ensure @body.close if @body.respond_to?(:close) deflater.close end |