Curb with a simpler multi interface and a new release 0.4.2
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…
- on_failure callbacks now include curb error codes as well as the easy handle.
- Multi Interface
- Support obscure error codes from sites like yahoo.com
- Ruby 1.9 support
- Support setting cookies
- Curl::Easy requests do not block other ruby threads
- Put support for uploading large files
- Updated to latest libcurl, including many new error codes
- Cent OS 4.5 support
- Improve build extconf.rb to auto detect curl-config
- Numerous other fixes and enhancements contributed
All of that and we have a new release: 0.4.2 on rubyforge.org.
gem install curb

Nice, this is a really clean interface.