Class: Rack::HeadersFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/headers_filter.rb

Constant Summary collapse

BLACKLIST_HEADERS =
%w[
  HTTP_X_FORWARDED_HOST
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, blacklist_headers: BLACKLIST_HEADERS) ⇒ HeadersFilter

Returns a new instance of HeadersFilter.



9
10
11
12
# File 'lib/rack/headers_filter.rb', line 9

def initialize(app, blacklist_headers: BLACKLIST_HEADERS)
  @remove_headers = blacklist_headers
  @app = app
end

Instance Attribute Details

#remove_headersObject (readonly)

Returns the value of attribute remove_headers.



7
8
9
# File 'lib/rack/headers_filter.rb', line 7

def remove_headers
  @remove_headers
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
# File 'lib/rack/headers_filter.rb', line 14

def call(env)
  @remove_headers.each { |header| env.delete(header) }
  @app.call(env)
end