Sha256: c898196ba28ec390f5b185d064380da35527b725233cebb33f13654bdc829f37

Contents?: true

Size: 609 Bytes

Versions: 10

Compression:

Stored size: 609 Bytes

Contents

module Excon
  module Middleware
    class Decompress < Excon::Middleware::Base
      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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
excon-0.29.0 lib/excon/middlewares/decompress.rb
excon-0.28.0 lib/excon/middlewares/decompress.rb
excon-0.27.6 lib/excon/middlewares/decompress.rb
excon-0.27.5 lib/excon/middlewares/decompress.rb
excon-0.27.4 lib/excon/middlewares/decompress.rb
excon-0.27.3 lib/excon/middlewares/decompress.rb
excon-0.27.2 lib/excon/middlewares/decompress.rb
excon-0.27.1 lib/excon/middlewares/decompress.rb
excon-0.27.0 lib/excon/middlewares/decompress.rb
excon-0.26.0 lib/excon/middlewares/decompress.rb