@@ -52,21 +52,23 @@ def append_features(base)
5252
5353 def header_hash ( options = nil )
5454 ALL_HEADER_CLASSES . inject ( { } ) do |memo , klass |
55- config = if options . is_a? ( Hash ) && options [ klass ::Constants ::CONFIG_KEY ]
55+ # must use !options[key].nil? because 'false' represents opting out, nil
56+ # represents use global default.
57+ config = if options . is_a? ( Hash ) && !options [ klass ::Constants ::CONFIG_KEY ] . nil?
5658 options [ klass ::Constants ::CONFIG_KEY ]
5759 else
5860 ::SecureHeaders ::Configuration . send ( klass ::Constants ::CONFIG_KEY )
5961 end
6062
6163 unless klass == SecureHeaders ::PublicKeyPins && !config . is_a? ( Hash )
62- header = get_a_header ( klass :: Constants :: CONFIG_KEY , klass , config )
63- memo [ header . name ] = header . value
64+ header = get_a_header ( klass , config )
65+ memo [ header . name ] = header . value if header
6466 end
6567 memo
6668 end
6769 end
6870
69- def get_a_header ( name , klass , options )
71+ def get_a_header ( klass , options )
7072 return if options == false
7173 klass . new ( options )
7274 end
@@ -210,7 +212,7 @@ def secure_header_options_for(type, options)
210212 def set_a_header ( name , klass , options = nil )
211213 options = secure_header_options_for ( name , options )
212214 return if options == false
213- set_header ( SecureHeaders ::get_a_header ( name , klass , options ) )
215+ set_header ( SecureHeaders ::get_a_header ( klass , options ) )
214216 end
215217
216218 def set_header ( name_or_header , value = nil )
0 commit comments