Sha256: 3c0674bcd45a829140ad2ffeb1d3e318e9962b03c9fd2d9422f80706b732791e

Contents?: true

Size: 516 Bytes

Versions: 12

Compression:

Stored size: 516 Bytes

Contents

require 'zlib'
require 'stringio'

module ZendeskAPI
  # @private
  module Middleware
    # @private
    module Response
      # Faraday middleware to handle content-encoding = gzip
      class Gzip < Faraday::Middleware
        def on_complete(env)
          return if env[:response_headers]['content-encoding'] != "gzip"
          return if env[:body].force_encoding(Encoding::BINARY).strip.empty?

          env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
zendesk_api-3.1.1 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.1.0 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.0.5 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.0.4 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.0.2 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.0.1 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.0.0 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-3.0.0.rc1 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-2.0.1 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-2.0.0 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.38.0.rc2 lib/zendesk_api/middleware/response/gzip.rb
zendesk_api-1.38.0.rc1 lib/zendesk_api/middleware/response/gzip.rb