Sha256: 2350bd7155e17dc59c43bd67bbe3ea45299bd891c2a294b17c57169ded82647f

Contents?: true

Size: 569 Bytes

Versions: 19

Compression:

Stored size: 569 Bytes

Contents

module Rack
  # Allows you to tap into the response headers. Yields a Rack::Utils::HeaderHash
  # of current response headers to the block. Example:
  #
  #   use Rack::ResponseHeaders do |headers|
  #     headers['X-Foo'] = 'bar'
  #     headers.delete('X-Baz')
  #   end
  #
  class ResponseHeaders
    def initialize(app, &block)
      @app = app
      @block = block
    end

    def call(env)
      response = @app.call(env)
      headers = Utils::HeaderHash.new(response[1])
      @block.call(headers)
      response[1] = headers
      response
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rack-contrib-2.2.0 lib/rack/contrib/response_headers.rb
rack-contrib-2.1.0 lib/rack/contrib/response_headers.rb
rack-contrib-2.0.1 lib/rack/contrib/response_headers.rb
rack-contrib-2.0.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.8.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.7.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.6.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.5.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.4.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.3.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.2.0.39.g17d21b4 lib/rack/contrib/response_headers.rb
rack-contrib-1.2.0 lib/rack/contrib/response_headers.rb
rack-contrib-1.1.0 lib/rack/contrib/response_headers.rb
corntrace-rack-contrib-1.0.2.3 lib/rack/contrib/response_headers.rb
corntrace-rack-contrib-1.0.2.2 lib/rack/contrib/response_headers.rb
corntrace-rack-contrib-1.0.2.1 lib/rack/contrib/response_headers.rb
corntrace-rack-contrib-1.0.2 lib/rack/contrib/response_headers.rb
rack-contrib-1.0.1 lib/rack/contrib/response_headers.rb
rack-contrib-1.0.0 lib/rack/contrib/response_headers.rb