curb(curl) for jruby?

十年热恋 提交于 2019-12-23 18:42:49

问题


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.

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 is what i would use if i could. any ideas?


回答1:


According to the curb documentation (http://curb.rubyforge.org/), curb is "Ruby-language bindings for the libcurl".

So unless the gem uses FFI, no it wont work with JRuby. I don't believe it will work with Windows either.

In jruby, you could make a shell call and use backticks to capture the output from curl.

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


来源:https://stackoverflow.com/questions/968136/curbcurl-for-jruby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!