Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#set_content_type
(::interned type, ?::Hash[untyped, untyped] params) -> void
set_content_type(type, params = {})
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/net/http/header.rb, line 817
def set_content_type(type, params = {})
set_field('Content-Type', type + params.map{|k,v|"; #{k}=#{v}"}.join(''))
end
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.