Created
February 6, 2013 04:48
-
-
Save oscardelben/4720399 to your computer and use it in GitHub Desktop.
Rack::MD5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/md5' | |
module Rack | |
# Adds the Content-MD5 entity header which provides a MD5 digest of | |
# the entity body for integrity check. | |
class MD5 | |
def initialize app | |
@app = app | |
end | |
def call env | |
status, headers, body = @app.call env | |
headers['Content-MD5'] = Digest::MD5.hexdigest(body.join("")) | |
[status, headers, body] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment