class HTTP::Features::AutoDeflate

Attributes

method[R]

Public Class Methods

new(*) click to toggle source
Calls superclass method HTTP::Feature.new
# File lib/http/features/auto_deflate.rb, line 10
def initialize(*)
  super

  @method = @opts.key?(:method) ? @opts[:method].to_s : "gzip"

  raise Error, "Only gzip and deflate methods are supported" unless %w[gzip deflate].include?(@method)
end

Public Instance Methods

deflated_body(body) click to toggle source
# File lib/http/features/auto_deflate.rb, line 18
def deflated_body(body)
  case method
  when "gzip"
    GzippedBody.new(body)
  when "deflate"
    DeflatedBody.new(body)
  else
    raise ArgumentError, "Unsupported deflate method: #{method}"
  end
end