Skip to content

Commit da0f027

Browse files
committed
set the header in default_headers if defined there
1 parent db5f4db commit da0f027

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/secure_headers.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,19 @@ 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-
response.headers[header.name] = header.value
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
161165
else
162166
response.headers[name_or_header] = value
163167
end
164168
end
169+
170+
def default_header?(name)
171+
Rails.application.config.action_dispatch.default_headers.has_key?(name)
172+
end
165173
end
166174
end
167175

0 commit comments

Comments
 (0)