Skip to content

Instantly share code, notes, and snippets.

@oscardelben
Created February 6, 2013 04:48
Show Gist options
  • Save oscardelben/4720399 to your computer and use it in GitHub Desktop.
Save oscardelben/4720399 to your computer and use it in GitHub Desktop.
Rack::MD5
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