@@ -50,12 +50,6 @@ def ensure_security_headers options = {}
5050 before_filter :set_x_download_options_header
5151 before_filter :set_x_permitted_cross_domain_policies_header
5252 end
53-
54- # we can't use ||= because I'm overloading false => disable, nil => default
55- # both of which trigger the conditional assignment
56- def options_for ( type , options )
57- options . nil? ? ::SecureHeaders ::Configuration . send ( type ) : options
58- end
5953 end
6054
6155 module InstanceMethods
@@ -80,7 +74,7 @@ def set_csp_header(req = nil, config=nil)
8074 end
8175
8276 config = self . class . secure_headers_options [ :csp ] if config . nil?
83- config = self . class . options_for :csp , config
77+ config = secure_header_options_for :csp , config
8478
8579 return if config == false
8680
@@ -140,7 +134,7 @@ def set_hsts_header(options=self.class.secure_headers_options[:hsts])
140134
141135 def set_hpkp_header ( options = self . class . secure_headers_options [ :hpkp ] )
142136 return unless request . ssl?
143- config = self . class . options_for :hpkp , options
137+ config = secure_header_options_for :hpkp , options
144138
145139 return if config == false || config . nil?
146140
@@ -158,8 +152,15 @@ def set_x_permitted_cross_domain_policies_header(options=self.class.secure_heade
158152
159153 private
160154
155+ # we can't use ||= because I'm overloading false => disable, nil => default
156+ # both of which trigger the conditional assignment
157+ def secure_header_options_for ( type , options )
158+ options . nil? ? ::SecureHeaders ::Configuration . send ( type ) : options
159+ end
160+
161+
161162 def set_a_header ( name , klass , options = nil )
162- options = self . class . options_for name , options
163+ options = secure_header_options_for name , options
163164 return if options == false
164165
165166 header = klass . new ( options )
0 commit comments