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
- #close ⇒ Object
- #each ⇒ Object
-
#initialize(body) ⇒ DeflateStream
constructor
A new instance of DeflateStream.
Constructor Details
#initialize(body) ⇒ DeflateStream
Returns a new instance of DeflateStream.
113 114 115 116 |
# File 'lib/rack/deflater.rb', line 113 def initialize(body) @body = body @closed = false end |
Instance Method Details
#close ⇒ Object
127 128 129 130 131 |
# File 'lib/rack/deflater.rb', line 127 def close return if @closed @closed = true @body.close if @body.respond_to?(:close) end |
#each ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/rack/deflater.rb', line 118 def each deflator = ::Zlib::Deflate.new(*DEFLATE_ARGS) @body.each { |part| yield deflator.deflate(part, Zlib::SYNC_FLUSH) } yield deflator.finish nil ensure deflator.close end |