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.0.0/lib/net/http/header.rb, line 776
def set_content_type(type, params = {})
@header['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.