Class: EventMachine::HttpDecoders::GZip

Inherits:
Base
  • Object
show all
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

#<<, #finalize!, #initialize

Constructor Details

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

Class Method Details

.encoding_namesObject



100
101
102
# File 'lib/em-http/decoders.rb', line 100

def self.encoding_names
  %w(gzip compressed)
end

Instance Method Details

#decompress(compressed) ⇒ Object



104
105
106
107
108
# File 'lib/em-http/decoders.rb', line 104

def decompress(compressed)
  @buf ||= ''
  @buf += compressed
  nil
end

#finalizeObject



110
111
112
# File 'lib/em-http/decoders.rb', line 110

def finalize
  Zlib::GzipReader.new(StringIO.new(@buf)).read
end