Class: EventMachine::HttpDecoders::GZip

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

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

+ (Object) encoding_names



219
220
221
# File 'lib/em-http/decoders.rb', line 219

def self.encoding_names
  %w(gzip compressed)
end

Instance Method Details

- (Object) decompress(compressed)



223
224
225
226
227
228
229
230
231
232
233
# File 'lib/em-http/decoders.rb', line 223

def decompress(compressed)
  @header ||= GZipHeader.new
  if !@header.finished?
    compressed = @header.extract_stream(compressed)
  end

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

- (Object) finalize



235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/em-http/decoders.rb', line 235

def finalize
  if @zstream
    if !@zstream.finished?
      r = @zstream.finish
    end
    @zstream.close
    r
  else
    nil
  end
rescue Zlib::Error
  raise DecoderError
end