Method: Gem::Net::HTTPHeader#set_content_type

Defined in:
lib/rubygems/net-http/lib/net/http/header.rb

#set_content_type(type, params = {}) ⇒ Object Also known as: content_type=

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

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

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



772
773
774
# File 'lib/rubygems/net-http/lib/net/http/header.rb', line 772

def set_content_type(type, params = {})
  @header['content-type'] = [type + params.map{|k,v|"; #{k}=#{v}"}.join('')]
end