Class: Excon::Middleware::Decompress

Inherits:
Base
  • Object
show all
Defined in:
lib/excon/middlewares/decompress.rb

Instance Method Summary collapse

Methods inherited from Base

#error_call, #initialize, #request_call

Constructor Details

This class inherits a constructor from Excon::Middleware::Base

Instance Method Details

#response_call(datum) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/excon/middlewares/decompress.rb', line 4

def response_call(datum)
  unless datum.has_key?(:response_block)
    case datum[:response][:headers]['Content-Encoding']
    when 'deflate'
      # assume inflate omits header
      datum[:response][:body] = Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(datum[:response][:body])
    when 'gzip'
      datum[:response][:body] = Zlib::GzipReader.new(StringIO.new(datum[:response][:body])).read
    end
  end
  @stack.response_call(datum)
end