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.
88 89 90 |
# File 'lib/rack/deflater.rb', line 88 def initialize(body) @body = body end |
Instance Method Details
#each ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/rack/deflater.rb', line 92 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 |