# File lib/mixlib/authentication/signedheaderauth.rb, line 182 def hashed_body(digest = OpenSSL::Digest::SHA1) # This is weird. sign() is called with the digest type and signing # version. These are also expected to be properties of the object. # Hence, we're going to assume the one that is passed to sign is # the correct one and needs to passed through all the functions # that do any sort of digest. @hashed_body_digest = nil unless defined?(@hashed_body_digest) if !@hashed_body_digest.nil? && @hashed_body_digest != digest raise "hashed_body must always be called with the same digest" else @hashed_body_digest = digest end # Hash the file object if it was passed in, otherwise hash based on # the body. # TODO: tim 2009-12-28: It'd be nice to just remove this special case, # always sign the entire request body, using the expanded multipart # body in the case of a file being include. @hashed_body ||= if file && file.respond_to?(:read) digester.hash_file(file, digest) else digester.hash_string(body, digest) end end