Sha256: b644ab43a4308702957eb94606ea8b3c21fcd3cc13136256b8efebafb7c57fdf

Contents?: true

Size: 520 Bytes

Versions: 12

Compression:

Stored size: 520 Bytes

Contents

require 'zlib'
require 'stringio'

module ZendeskAPI
  # @private
  module Middleware
    # @private
    module Response
      # Faraday middleware to handle content-encoding = gzip
      class Gzip < Faraday::Response::Middleware
        def on_complete(env)
          if env[:body].respond_to?(:to_str) && !env[:body].strip.empty? && env[:response_headers]['content-encoding'] == "gzip"
            env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
zendesk_api-1.4.0 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.9 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.8 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.7 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.5 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.4 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.2 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.1 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.0 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.0.rc3 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.0.rc2 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.3.0.rc1 lib/zendesk_api/middleware/response/gzip.rb