Skip to content

Commit e1926b7

Browse files
committed
delete conflicting headers in initializer
1 parent da0f027 commit e1926b7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/secure_headers.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,11 @@ def set_a_header(name, klass, options=nil)
157157
def set_header(name_or_header, value=nil)
158158
if name_or_header.is_a?(Header)
159159
header = name_or_header
160-
if default_header?(header.name)
161-
Rails.application.config.action_dispatch.default_headers[header.name] = header.value
162-
else
163-
response.headers[header.name] = header.value
164-
end
160+
response.headers[header.name] = header.value
165161
else
166162
response.headers[name_or_header] = value
167163
end
168164
end
169-
170-
def default_header?(name)
171-
Rails.application.config.action_dispatch.default_headers.has_key?(name)
172-
end
173165
end
174166
end
175167

lib/secure_headers/railtie.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
module SecureHeaders
44
class Railtie < Rails::Engine
55
isolate_namespace ::SecureHeaders if defined? isolate_namespace # rails 3.0
6+
conflicting_headers = ['X-Frame-Options', 'X-XSS-Protection', 'X-Content-Options']
67
initializer "secure_headers.action_controller" do
78
ActiveSupport.on_load(:action_controller) do
89
include ::SecureHeaders
10+
11+
conflicting_headers.each do |header|
12+
Rails.application.config.action_dispatch.default_headers.delete[header]
13+
end
14+
915
end
1016
end
1117
end

0 commit comments

Comments
 (0)