Sha256: 9e5442f3a0a10e974dbaaed9cff2b34be8351deb32d4b3c103d8ffd3661bb36c

Contents?: true

Size: 499 Bytes

Versions: 16

Compression:

Stored size: 499 Bytes

Contents

require 'digest/md5'

module Rack
  # Automatically sets the ETag header on all String bodies
  class ETag
    def initialize(app)
      @app = app
    end

    def call(env)
      status, headers, body = @app.call(env)

      if !headers.has_key?('ETag')
        parts = []
        body.each { |part| parts << part.to_s }
        headers['ETag'] = %("#{Digest::MD5.hexdigest(parts.join(""))}")
        [status, headers, parts]
      else
        [status, headers, body]
      end
    end
  end
end

Version data entries

16 entries across 15 versions & 6 rubygems

Version Path
rack-1.1.6 lib/rack/etag.rb
rack-1.1.5 lib/rack/etag.rb
rack-1.1.4 lib/rack/etag.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rack-1.1.3/lib/rack/etag.rb
rack-1.1.3 lib/rack/etag.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rack-1.1.2/lib/rack/etag.rb
rack-1.1.2 lib/rack/etag.rb
rack-1.1.1 lib/rack/etag.rb
rack-1.1.1.pre lib/rack/etag.rb
eac-rack-1.1.1 lib/rack/etag.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/etag.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/rack-1.1.0/lib/rack/etag.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/etag.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/etag.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/rack-1.1.0/lib/rack/etag.rb
rack-1.1.0 lib/rack/etag.rb