instance method
Net::HTTPHeader#[]=
(::interned key, untyped val) -> void
[]=(key, val)
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/net/http/header.rb, line 242
def []=(key, val)
unless val
@header.delete key.downcase.to_s
return val
end
set_field(key, val)
end
Sets the value for the case-insensitive key to val, overwriting the previous value if the field exists; see Fields:
Example
req = Net::HTTP::Get.new(uri) req['Accept'] # => "*/*" req['Accept'] = 'text/html' req['Accept'] # => "text/html"
Note that some field values may be set via convenience methods; see Setters.