Module: HTTPX::Plugins::ContentDigest::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#build_requestObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/httpx/plugins/content_digest.rb', line 96

def build_request(*)
  request = super

  return request if request.empty?

  return request if request.headers.key?("content-digest")

  perform_encoding = @options.encode_content_digest
  perform_encoding = perform_encoding.call(request) if perform_encoding.respond_to?(:call)

  return request unless perform_encoding

  digest = base64digest(request.body)
  request.headers.add("content-digest", "#{@options.content_digest_algorithm}=:#{digest}:")

  request
end