lib/jkl/rest_client.rb in jakal-0.1.95 vs lib/jkl/rest_client.rb in jakal-0.1.96
- old
+ new
@@ -8,28 +8,34 @@
begin
uri = URI.parse(url)
resp, data = Net::HTTP.post_form(uri, post_args)
data
rescue URI::InvalidURIError => e
- puts("WARN: Invalid URI: #{e}")
+ puts("WARN: JKL Invalid URI: #{e}")
rescue SocketError => e
- puts("WARN: Could not connect: #{e}")
+ puts("WARN: JKL Could not connect: #{e}")
rescue Errno::ECONNREFUSED => e
- puts("WARN: Connection refused: #{e}")
+ puts("WARN: JKL Connection refused: #{e}")
end
end
def get_from(uri)
begin
response = Net::HTTP.get_response(URI.parse(uri))
response.body
rescue URI::InvalidURIError => e
- puts("WARN: Invalid URI: #{e}")
+ puts("WARN: JKL Invalid URI: #{e}")
rescue SocketError => e
- puts("WARN: Could not connect: #{e}")
+ puts("WARN: JKL Could not connect: #{e}")
rescue Errno::ECONNREFUSED => e
- puts("WARN: Connection refused: #{e}")
+ puts("WARN: JKL Connection refused: #{e}")
end
+ end
+
+ def get_from_over_https(host, path)
+ http = Net::HTTP.new(host, "443")
+ http.use_ssl = true
+ http.get2(path) # returns [status, data]
end
def get_xml_from(uri)
Hpricot.XML(get_from(uri))
end