class Async::HTTP::Body::ZStream
def self.encoding_name(window_size)
def self.encoding_name(window_size) if window_size <= -8 return 'deflate' elsif window_size >= 16 return 'gzip' else return 'compress' end end
def initialize(body, stream)
def initialize(body, stream) super(body) @stream = stream @input_length = 0 @output_length = 0 end
def inspect
def inspect "#{super} | \#<#{self.class} #{(ratio*100).round(2)}%>" end
def length
def length # We don't know the length of the output until after it's been compressed. nil end
def ratio
def ratio if @input_length != 0 @output_length.to_f / @input_length.to_f else 1.0 end end
def stop(error)
def stop(error) # There are two ways for the stream to be closed. Either #read returns nil or #stop is called. @stream.close unless @stream.closed? super end