Class: Async::HTTP::Body::Deflate
- Defined in:
- lib/async/http/body/deflate.rb
Constant Summary
Constants inherited from ZStream
ZStream::DEFAULT_LEVEL, ZStream::DEFLATE, ZStream::ENCODINGS, ZStream::GZIP
Instance Attribute Summary
Attributes inherited from ZStream
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ZStream
encoding_name, #initialize, #inspect, #length, #ratio, #stop
Methods inherited from Wrapper
#close, #empty?, #initialize, #inspect, #length, #stop
Methods inherited from Readable
#close, #each, #empty?, #join, #length, #stop
Constructor Details
This class inherits a constructor from Async::HTTP::Body::ZStream
Class Method Details
.for(body, window_size = GZIP, level = DEFAULT_LEVEL) ⇒ Object
87 88 89 |
# File 'lib/async/http/body/deflate.rb', line 87 def self.for(body, window_size = GZIP, level = DEFAULT_LEVEL) self.new(body, Zlib::Deflate.new(level, window_size)) end |
Instance Method Details
#read ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/async/http/body/deflate.rb', line 91 def read return if @stream.closed? if chunk = super @input_length += chunk.bytesize chunk = @stream.deflate(chunk, Zlib::SYNC_FLUSH) @output_length += chunk.bytesize return chunk else chunk = @stream.finish @output_length += chunk.bytesize @stream.close return chunk.empty? ? nil : chunk end end |