Class: ZendeskAPI::Middleware::Response::Gzip

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/zendesk_api/middleware/response/gzip.rb

Overview

Faraday middleware to handle content-encoding = gzip

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



11
12
13
14
15
# File 'lib/zendesk_api/middleware/response/gzip.rb', line 11

def on_complete(env)
  if !env[:body].strip.empty? && env[:response_headers]['content-encoding'] == "gzip"
    env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
  end
end