Class: Rack::Deflater::DeflateStream

Inherits:
Object
  • Object
show all
Defined in:
rack/rack/deflater.rb

Constant Summary

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)

Constructor Details

- (DeflateStream) initialize(body)

Returns a new instance of DeflateStream



101
102
103
# File 'rack/rack/deflater.rb', line 101

def initialize(body)
  @body = body
end

Instance Method Details

- (void) each



105
106
107
108
109
110
111
112
113
# File 'rack/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