Home > Software > Curb with a simpler multi interface and a new release 0.4.2

Curb with a simpler multi interface and a new release 0.4.2

June 25th, 2009

Curb provides ruby bindings for libcurl.  Last year around this time, I decided to start hacking on curb by adding support for libcurl’s multi interface.   At the time, I remember wanting to have an interface as similar to curl-multi as possible, but with the added benefit of being able to initialize requests using the features of Curl::Easy.   The upside of this approach is any easy handle can be configured and dispatched through a Multi handle in parallel. The downside is the interface can be complicated for simple use cases. To simplify the interface, I added a more direct method for sending multiple concurrent requests.   Here’s how the new interface works:

Curl::Multi.get('http://www.google.com/',
                'http://www.yahoo.com/',
                'http://www.msn.com/') do|easy|
  puts easy.header_str
end

Now that’s great you issue multiple GET requests using a default easy handle configuration. As each request is completed, it yield’s passing the easy handle to the block.

The get method also can be passed 2 additional Hash arguments that configure each easy handle and the multi handle.  For example,

Curl::Multi.get('http://www.google.com/',
                'http://www.yahoo.com/',
                'http://www.msn.com/',
                {:follow_location => true},
                {:pipeline => true}) do|easy|
  puts easy.header_str
end

You can try it out using my github branch or stay tuned I should have a new release ready for rubyforge soon.

Also, I thought it would be nice to reflect on many of the changes collected over the course of the year…

All of that and we have a new release: 0.4.2 on rubyforge.org.

   gem install curb

Software

  1. June 25th, 2009 at 13:10 | #1

    Nice, this is a really clean interface.

  1. No trackbacks yet.
CommentLuv Enabled

Comments links could be nofollow free.