class Excon::Middleware::Decompress

def response_call(datum)

def response_call(datum)
  body = datum[:response][:body]
  unless datum.has_key?(:response_block) || body.nil? || body.empty?
    if key = datum[:response][:headers].keys.detect {|k| k.casecmp('Content-Encoding') == 0 }
      encodings = Utils.split_header_value(datum[:response][:headers][key])
      if encoding = encodings.last
        if encoding.casecmp('deflate') == 0
          # assume inflate omits header
          datum[:response][:body] = Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(body)
          encodings.pop
        elsif encoding.casecmp('gzip') == 0 || encoding.casecmp('x-gzip') == 0
          datum[:response][:body] = Zlib::GzipReader.new(StringIO.new(body)).read
          encodings.pop
        end
        datum[:response][:headers][key] = encodings.join(', ')
      end
    end
  end
  @stack.response_call(datum)
end