jruby的遏制(curl)? [英] curb(curl) for jruby?
问题描述
我正在尝试将curl与jruby结合使用,以获取网页/文件的一些响应时间。通常在红宝石中这不是问题,我可以只安装gem(宝石安装路缘),一切都很好。
i'm trying to use curl with jruby to get some response times for webpages/files. normally in ruby this would not be an issue and i could just install the gem (gem install curb) and all is well.
路缘似乎与jruby不兼容,所以我可以用类似的方式来获取网页加载时间吗?我查看了net / http类,但是它没有可以正常工作的功能
curb appears to be incompatible with jruby, so is there an alternative that i can use to get web page load times in a similar fashion? i looked into the net/http class however it doesn't have a function that would work
curl.total_time是我可以使用的。有任何想法吗?
curl.total_time is what i would use if i could. any ideas?
推荐答案
根据路边文档( http://curb.rubyforge.org/ ),遏制是 libcurl的Ruby语言绑定。
According to the curb documentation (http://curb.rubyforge.org/), curb is "Ruby-language bindings for the libcurl".
因此,除非gem使用FFI,不,它不能与JRuby一起使用。我也不相信它也可以在Windows上使用。
So unless the gem uses FFI, no it wont work with JRuby. I don't believe it will work with Windows either.
在jruby中,您可以进行shell调用并使用反引号来捕获curl的输出。
In jruby, you could make a shell call and use backticks to capture the output from curl.
或者您也可以这样使用Net :: HTTP和Time:
Or you could use Net::HTTP and Time like so:
require 'net/http'
require 'time'
s = Time.new
html = Net::HTTP.get(URI.parse('http://yoursite/'))
puts Time.new - s
这篇关于jruby的遏制(curl)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!