Class: EventMachine::HttpDecoders::Deflate

Inherits:
Base
  • Object
show all
Defined in:
lib/em-http/decoders.rb

Instance Method Summary (collapse)

Methods inherited from Base

#<<, encoding_names, #finalize!, #initialize

Constructor Details

This class inherits a constructor from EventMachine::HttpDecoders::Base

Instance Method Details

- (Object) decompress(compressed)



72
73
74
75
76
77
78
79
# File 'lib/em-http/decoders.rb', line 72

def decompress(compressed)
  begin
    @zstream ||= Zlib::Inflate.new(-Zlib::MAX_WBITS)
    @zstream.inflate(compressed)
  rescue Zlib::Error
    raise DecoderError
  end
end

- (Object) finalize



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/em-http/decoders.rb', line 81

def finalize
  return nil unless @zstream

  begin
    r = @zstream.inflate(nil)
    @zstream.close
    r
  rescue Zlib::Error
    raise DecoderError
  end
end