开发者

What's the easiest way to get the result of an HTTP GET request in using URL in JRuby

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()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜