Tutorial :curb(curl) for jruby?



Question:

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?


Solution: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  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »