Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Net::HTTPHeader#set_content_type

(::interned type, ?::Hash[untyped, untyped] params) -> void
set_content_type(type, params = {})

Sets the value of field 'Content-Type'; returns the new value; see Content-Type request header:

Example
req = Net::HTTP::Get.new(uri)
req.set_content_type('application/json') # => ["application/json"]

Net::HTTPHeader#content_type= is an alias for Net::HTTPHeader#set_content_type.

See also #range_length #set_field #range= #set_form also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0