class Protocol::HTTP::Body::ZStream
A body which compresses or decompresses the contents using the DEFLATE or GZIP algorithm.
def close(error = nil)
Close the stream.
def close(error = nil) if stream = @stream @stream = nil stream.close unless stream.closed? end super end
def initialize(body, stream)
@parameter body [Readable] the body to wrap.
Initialize the body with the given stream.
def initialize(body, stream) super(body) @stream = stream @input_length = 0 @output_length = 0 end
def inspect
Inspect the body, including the compression ratio.
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
The compression ratio, according to the input and output lengths.
def ratio if @input_length != 0 @output_length.to_f / @input_length.to_f else 1.0 end end