Skip to content
instance method

Net::HTTPHeader#[]=

(::interned key, untyped val) -> void
[]=(key, val)

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.

See also #[] #add_field #basic_auth also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0