lib/rack/contrib/content_hash.rb in rack-content-hash-0.0.1 vs lib/rack/contrib/content_hash.rb in rack-content-hash-0.0.2

- old
+ new

@@ -13,11 +13,11 @@ # # Ex: # use Rack::Contrib::ContentHash, md5: true, sha1: true # class ContentHash - VERSION = '0.0.1' + VERSION = '0.0.2' # Initialize the middleware, pass a Hash of algorithms in the second # parameter. Ex: .new app, md5: true, sha1: false def initialize app, algorithms = {} @app = app @@ -26,11 +26,12 @@ # Hash the body of your response, and append the headers to the Hash def call env status, headers, body = @app.call env - headers['Content-MD5'] = Digest::MD5.hexdigest(body) if @algo[:md5] - headers['Content-SHA1'] = Digest::SHA1.hexdigest(body) if @algo[:sha1] + hashbody = body.join "" + headers['Content-MD5'] = Digest::MD5.hexdigest(hashbody) if @algo[:md5] + headers['Content-SHA1'] = Digest::SHA1.hexdigest(hashbody) if @algo[:sha1] [status, headers, body] end end end