Sha256: 57520c760658f120738c0e75ead875edac5fcbf2b356e090e75651a9ee8dbbc0

Contents?: true

Size: 520 Bytes

Versions: 7

Compression:

Stored size: 520 Bytes

Contents

require 'rack/utils'

module Murlsh

  # Rack middleware to add the content encoding to the end of the ETag because
  # ETag must be different for different representations.
  class EtagAddEncoding

    def initialize(app); @app = app; end

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

      headers = Rack::Utils::HeaderHash.new(headers)

      if headers['ETag']
        headers['ETag'].sub!(/(")?$/, "#{headers['Content-Encoding']}\\1")
      end

      [status, headers, body]
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
murlsh-1.4.1 lib/murlsh/etag_add_encoding.rb
murlsh-1.4.0 lib/murlsh/etag_add_encoding.rb
murlsh-1.3.1 lib/murlsh/etag_add_encoding.rb
murlsh-1.3.0 lib/murlsh/etag_add_encoding.rb
murlsh-1.2.1 lib/murlsh/etag_add_encoding.rb
murlsh-1.2.0 lib/murlsh/etag_add_encoding.rb
murlsh-1.1.0 lib/murlsh/etag_add_encoding.rb