本文介绍了无法在https协议中使用curl,httparty或net :: http获取任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用https进行任何操作。
I am having trouble to get anything using https.
我无法获取任何内容:
curl -k https://graph.facebook.com
或
uri = URI('https://graph.facebook.com/davidarturo')
Net::HTTP.get(uri)
我得到:
error: EOFError: end of file reached
还有没有运气与httparty和https
Also there is no luck with httparty and https
推荐答案
当你使用https协议,你必须明确告诉使用 net / http
库:
As you use 'https' protocol, you must explicitly tell about it in case of using net/http
library:
require 'net/http'
uri = URI('https://graph.facebook.com/davidarturo')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'
http.start do |h|
response = h.request Net::HTTP::Get.new(uri.request_uri)
puts response.body if Net::HTTPSuccess
end
这篇关于无法在https协议中使用curl,httparty或net :: http获取任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!