class Async::HTTP::AcceptEncoding
Set a valid accept-encoding header and decode the response.
def call(request)
def call(request) request.headers['accept-encoding'] = @accept_encoding response = super if !response.body.empty? and content_encoding = response.headers['content-encoding'] body = response.body # We want to unwrap all encodings content_encoding.reverse_each do |name| if wrapper = @wrappers[name] body = wrapper.call(body) end end response.body = body end return response end
def initialize(app, wrappers = DEFAULT_WRAPPERS)
def initialize(app, wrappers = DEFAULT_WRAPPERS) super(app) @accept_encoding = wrappers.keys.join(', ') @wrappers = wrappers end