I have the following Method:
http_client=Net::HTTP.new(@uri.host,@uri.port)
request=Net::HTTP::Post.new(@uri.request_uri)
request.set_form_data(params)
request.basic_auth(@user,@pass)
result = http_client.request(request)
#
# !!! .content_type does not exist !!!
#
result=case result.content_type
when "application/json" JSON.parse(result,{:symbolize_names => true})
when "application/xml" XMLHELPER.parse(result)
end
result
So how to determine the content-type that was sent by the server?
You’re getting a
NoMethodErrorfrom callingresult.content_typebecause you’ve assignedresultto the response body, which is a string.