Module: HTTPX::Plugins::ContentDigest::ResponseBodyMethods

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#content_digest_bufferObject (readonly)

Returns the value of attribute content_digest_buffer.



62
63
64
# File 'lib/httpx/plugins/content_digest.rb', line 62

def content_digest_buffer
  @content_digest_buffer
end

Instance Method Details

#closeObject



86
87
88
89
90
91
92
# File 'lib/httpx/plugins/content_digest.rb', line 86

def close
  if @content_digest_buffer
    @content_digest_buffer.close
    @content_digest_buffer = nil
  end
  super
end

#initialize(response, options) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/httpx/plugins/content_digest.rb', line 64

def initialize(response, options)
  super

  return unless response.headers.key?("content-digest")

  should_validate = options.validate_content_digest
  should_validate = should_validate.call(response) if should_validate.respond_to?(:call)

  return unless should_validate

  @content_digest_buffer = Response::Buffer.new(
    threshold_size: @options.body_threshold_size,
    bytesize: @length,
    encoding: @encoding
  )
end

#write(chunk) ⇒ Object



81
82
83
84
# File 'lib/httpx/plugins/content_digest.rb', line 81

def write(chunk)
  @content_digest_buffer.write(chunk) if @content_digest_buffer
  super
end