开发者

Https call giving exception

开发者 https://www.devze.com 2023-03-31 18:07 出处:网络
My code is like encodestring = \"test@gmail.com:test\" enc = Base64.encode64(encodestring) auth = \"Basic #{enc}\"

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消