I think your call http.request(uri)
is wrong, you should pass a kind of request object like Net::HTTP::Get
instead of the uri
. Try with the following code:
require 'net/http'
uri = URI('https://example.com:8443')
http = Net::HTTP.new(uri.host, uri.port)
# Enable SSL/TLS ?
if uri.scheme == "https"
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file = File.join(File.dirname(__FILE__), "ca-rsa-cert.pem")
end
req = Net::HTTP::Get.new('/')
http.request(req)
Or call directly request_get('/')
. That method will create the Get
object for you, like the documentation explain:
def request_get(path, initheader = nil, &block) # :yield: +response+
request(Get.new(path, initheader), &block)
end