Class: EventMachine::HttpDecoders::GZip
- Defined in:
- lib/em-http/decoders.rb
Overview
Oneshot decompressor, due to lack of a streaming Gzip reader implementation. We may steal code from Zliby to improve this.
For now, do not put ‘gzip’ or ‘compressed’ in your accept-encoding header if you expect much data through the :on_response interface.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from EventMachine::HttpDecoders::Base
Class Method Details
.encoding_names ⇒ Object
101 102 103 |
# File 'lib/em-http/decoders.rb', line 101 def self.encoding_names %w(gzip compressed) end |
Instance Method Details
#decompress(compressed) ⇒ Object
105 106 107 108 109 |
# File 'lib/em-http/decoders.rb', line 105 def decompress(compressed) @buf ||= '' @buf += compressed nil end |
#finalize ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/em-http/decoders.rb', line 111 def finalize begin Zlib::GzipReader.new(StringIO.new(@buf.to_s)).read rescue Zlib::Error raise DecoderError end end |