class Protocol::HTTP::Body::Digestable

def self.wrap(message, digest = Digest::SHA256.new, &block)

@parameter block [Proc] the callback to invoke when the body is closed.
@parameter digest [Digest] the digest to use.
@parameter message [Request | Response] the message body.

Wrap a message body with a callback. If the body is empty, the callback is not invoked, as there is no data to digest.
def self.wrap(message, digest = Digest::SHA256.new, &block)
	if body = message&.body and !body.empty?
		message.body = self.new(message.body, digest, block)
	end
end