I'm attempting to build a Tropo Ruby application and I need to retrieve the result of an HTTPS GET. The Tropo platform doesn't have the httpclient Ruby gem so I can't use that. The Ruby engine used is JRuby so a suggestio开发者_开发百科n has been to make use of the Java URL class to do the request. I've played around with it a little bit and I seem to be able to create the URL object ok but am now struggling with how to get the results of executing the request. How do I do it?
javaURL = java.net.URL.new svcURL
transferResult = javaURL.getContent()
I am not sure what getContent() does exactly, but you can use openStream() which gives you an InputStream to read from.
javaURL = java.net.URL.new svcURL
transfer = javaURL.openStream()
// read from stream
transfer.close()
精彩评论