Https call giving exception
My code is like
encodestring = "test@gmail.com:test"
enc = Base64.encode64(encodestring)
auth = "Basic #{enc}"
https = Net::HTTP.new('localhost', 443)
https.use_ssl = true
path = '/user/test'
query_string = "#{auth}"
https.verify_mode = OpenSSL::SSL::VERIFY_NONE # don't display warnings
resp = https.post(path,query_string)
here test is a method inside user_controller.rb file.If i am making simple http request its working fine but while making https request开发者_JAVA百科 it is giving exception "SocketError (initialize: name or service not known)".Please help me to make it a valid https call. thanks in advance.
The examples I've seen have taken a host name as the first argument to HTTP.new
, rather than a URL. Try this:
https = Net::HTTP.new('localhost', 443)
It's not clear whether you actually want to connect to port 443 or 3001 - you obviously can't connect to both. If you want 3001, replace the 443 above.
精彩评论