6 class Gzip < Faraday::Response::Middleware
7 include Google::APIClient::Logging
10 encoding = env[:response_headers]['content-encoding'].to_s.downcase
13 logger.debug { "Decompressing gzip encoded response (#{env[:body].length} bytes)" }
14 env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
15 env[:response_headers].delete('content-encoding')
16 logger.debug { "Decompressed (#{env[:body].length} bytes)" }
18 logger.debug{ "Decompressing deflate encoded response (#{env[:body].length} bytes)" }
19 env[:body] = Zlib::Inflate.inflate(env[:body])
20 env[:response_headers].delete('content-encoding')
21 logger.debug { "Decompressed (#{env[:body].length} bytes)" }
28 Faraday::Response.register_middleware :gzip => Google::APIClient::Gzip