Module: HTTPX::Plugins::Compression::RequestBodyMethods

Defined in:
lib/httpx/plugins/compression.rb

Instance Method Summary collapse

Instance Method Details

#initialize(options) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/httpx/plugins/compression.rb', line 45

def initialize(*, options)
  super
  return if @body.nil?

  if (threshold = options.compression_threshold_size)
    unless unbounded_body?
      return if @body.bytesize < threshold
    end
  end

  @headers.get("content-encoding").each do |encoding|
    next if encoding == "identity"

    @body = Encoder.new(@body, Compression.registry(encoding).encoder)
  end
  @headers["content-length"] = @body.bytesize unless chunked?
end