lib/protocol/http/headers.rb in protocol-http-0.14.3 vs lib/protocol/http/headers.rb in protocol-http-0.14.4
- old
+ new
@@ -103,11 +103,23 @@
end
# This is deprecated.
alias slice! extract
+ # Add the specified header key value pair.
+ # @param key [String] the header key.
+ # @param value [String] the header value to assign.
def add(key, value)
self[key] = value
+ end
+
+ # Set the specified header key to the specified value, replacing any existing header keys with the same name.
+ # @param key [String] the header key to replace.
+ # @param value [String] the header value to assign.
+ def set(key, value)
+ # TODO This could be a bit more efficient:
+ self.delete(key)
+ self.add(key, value)
end
def merge!(headers)
headers.each do |key, value|
self[key] = value