Sha256: aeca903984263a664eed209d9c73081efa35f02e59c6bc473e8e02762a56dd35

Contents?: true

Size: 511 Bytes

Versions: 9

Compression:

Stored size: 511 Bytes

Contents

require 'zlib'

module Ridley
  module Middleware
    class Gzip < Faraday::Response::Middleware
      def on_complete(env)
        case env[:response_headers][CONTENT_ENCODING].to_s.downcase
        when 'gzip'
          env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body]), encoding: 'ASCII-8BIT').read
        when 'deflate'
          env[:body] = Zlib::Inflate.inflate(env[:body])
        end
      end
    end
  end
end

Faraday.register_middleware(:response, gzip: Ridley::Middleware::ChefResponse)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ridley-1.0.3 lib/ridley/middleware/gzip.rb
ridley-1.2.1 lib/ridley/middleware/gzip.rb
ridley-1.2.0 lib/ridley/middleware/gzip.rb
ridley-1.1.1 lib/ridley/middleware/gzip.rb
ridley-1.1.0 lib/ridley/middleware/gzip.rb
ridley-1.0.2 lib/ridley/middleware/gzip.rb
ridley-1.0.1 lib/ridley/middleware/gzip.rb
ridley-1.0.0 lib/ridley/middleware/gzip.rb
ridley-1.0.0.rc3 lib/ridley/middleware/gzip.rb