Object
Automatically sets the ETag header on all String bodies
# File lib/rack/etag.rb, line 6 6: def initialize(app) 7: @app = app 8: end
# File lib/rack/etag.rb, line 10 10: def call(env) 11: status, headers, body = @app.call(env) 12: 13: if !headers.has_key?('ETag') 14: digest, body = digest_body(body) 15: headers['ETag'] = %("#{digest}") 16: end 17: 18: [status, headers, body] 19: end
# File lib/rack/etag.rb, line 22 22: def digest_body(body) 23: digest = Digest::MD5.new 24: parts = [] 25: body.each do |part| 26: digest << part 27: parts << part 28: end 29: [digest.hexdigest, parts] 30: end
Disabled; run with --debug to generate this.
[Validate]
Generated with the Darkfish Rdoc Generator 1.1.6.