class Protocol::HTTP::Body::ZStream

Constants

DEFAULT_LEVEL
DEFLATE
ENCODINGS
GZIP

Attributes

input_length[R]
output_length[R]

Public Class Methods

encoding_name(window_size) click to toggle source
# File lib/protocol/http/body/deflate.rb, line 41
def self.encoding_name(window_size)
        if window_size <= -8
                return 'deflate'
        elsif window_size >= 16
                return 'gzip'
        else
                return 'compress'
        end
end
new(body, stream) click to toggle source
Calls superclass method
# File lib/protocol/http/body/deflate.rb, line 51
def initialize(body, stream)
        super(body)
        
        @stream = stream
        
        @input_length = 0
        @output_length = 0
end

Public Instance Methods

close(error = nil) click to toggle source
Calls superclass method
# File lib/protocol/http/body/deflate.rb, line 60
def close(error = nil)
        @stream.close unless @stream.closed?
        
        super
end
inspect() click to toggle source
# File lib/protocol/http/body/deflate.rb, line 82
def inspect
        "#{super} | \#<#{self.class} #{(ratio*100).round(2)}%>"
end
length() click to toggle source
# File lib/protocol/http/body/deflate.rb, line 66
def length
        # We don't know the length of the output until after it's been compressed.
        nil
end
ratio() click to toggle source
# File lib/protocol/http/body/deflate.rb, line 74
def ratio
        if @input_length != 0
                @output_length.to_f / @input_length.to_f
        else
                1.0
        end
end