Method: HTTP::Protocol::Headers#merge
- Defined in:
- lib/http/protocol/headers.rb
#merge(hash, key, value) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/http/protocol/headers.rb', line 151 def merge(hash, key, value) if policy = MERGE_POLICY[key] if current_value = hash[key] current_value << value else hash[key] = policy.new(value) end else raise ArgumentError, "Header #{key} can only be set once!" if hash.include?(key) # We can't merge these, we only expose the last one set. hash[key] = value end end |