Sarav's Weblog

Technical Articles for RoR Developers

Curb Gem – Libcurl bindings for Ruby

Curb – Libcurl bindings for Ruby

  • *
  • *

Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the libcurl(3), a fully-featured client-side URL transfer library. cURL and libcurl live at .

Curb is a work-in-progress, and currently only supports libcurl’s ‘easy’ mode.

Curb is copyright (c)2006 Ross Bamford, and released under the terms of the Ruby license. See the LICENSE file for the gory details.
You will need

* A working Ruby installation (1.8+, tested with 1.8.5)
* A working (lib)curl installation, with development stuff (7.5+, tested with 7.15)
* A sane build environment

… will usually be as simple as:
$ gem install curb

Or, if you downloaded the archive:
$ rake install

If you have a wierd setup, you might need extconf options. In this case, pass them like so:

$ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'

Currently, Curb is tested only on GNU/Linux x86 – YMMV on other platforms. If you do use another platform and experience problems, or if you can expand on the above instructions, please get in touch via the mailing list on Curb’s Rubyforge page.

Curb has fairly extensive RDoc comments in the source. You can build the documentation with:

$ rake doc

Simple fetch via HTTP:

c = Curl::Easy.perform("")
puts c.body_str

Same thing, more manual:

c ="")
puts c.body_str

Additional config:

Curl::Easy.perform("") do |curl|
curl.headers["User-Agent"] = "myapp-0.0"
curl.verbose = true

Same thing, more manual:

c ="") do |curl|
curl.headers["User-Agent"] = "myapp-0.0"
curl.verbose = true


Supplying custom handlers:

c ="")

c.on_body { |data| print(data) }
c.on_header { |data| print(data) }


Reusing Curls:

c =

["", ""].map do |url|
c.url = url


c = Curl::Easy.http_post("",
Curl::PostField.content('thing[name]', 'box',
Curl::PostField.content('thing[type]', 'storage')

HTTP POST file upload:

c ="")
c.multipart_form_post = true

Resource from:


17 responses to “Curb Gem – Libcurl bindings for Ruby

  1. Pingback: Curb Gem โ€“ Libcurl bindings for Ruby keynote link for different customs

  2. Robert February 23, 2011 at 3:28 pm

    Great post!!!!!!!!! thank you

  3. saravani July 4, 2011 at 3:28 pm

    Thanks Robert

  4. Matt November 13, 2011 at 11:06 pm


    I have tried this simple example below:

    c = Curl::Easy.perform(“”)
    puts c.body_str

    Unfortunately I get this result. Do you know how I can resolve this?

    test.rb:1:in `’: uninitialized constant Object::Curl (NameError)

    Many thanks,

  5. Anonymous June 15, 2012 at 10:02 am

    congratulations! You managed to copy the readme and repost it!

  6. Anonymous June 15, 2012 at 12:09 pm

    @Anonymous – I didn’t say it is my original content. You can see at bottom of the line for the reference. Resource from:

  7. Anonymous September 7, 2012 at 11:04 pm

    Curl::Err::SSLConnectError (SSL connect error):

    curlObj =“”)
    curlObj.connect_timeout = 0
    curlObj.timeout = 0
    curlObj.post_body = query
    data = curlObj.body_str

    Dnt know why this error is cmg… Please help

  8. Pingback: API Best Practices | Open Source Coding | Sharing Codes - All the curl samples you ever need to get started

  9. Jerri October 25, 2012 at 1:11 am

    I almost never comment, but i did some searching and wound up here Curb Gem –
    Libcurl bindings for Ruby ซ Sarav’s Weblog. And I actually do have some questions for you if you tend not to mind. Could it be just me or does it look as if like a few of the responses come across like they are written by brain dead individuals? ๐Ÿ˜› And, if you are posting on other sites, I’d like to
    keep up with anything new you have to post. Could you make
    a list of all of your social pages like your twitter feed, Facebook
    page or linkedin profile?

  10. saravani November 20, 2012 at 6:18 pm

    Hi Jerri,

    My brain is still live ๐Ÿ™‚ . I stopped blogging for a while. Now I’m back. I’ll keep posting hereafter. Let me know what are the questions you have?

    P.S Sorry for the delayed reply ๐Ÿ™‚

    twitter –
    FB –

  11. black friday 2012 deals November 21, 2012 at 3:18 am

    Hello there! Quick question that’s totally off topic. Do you know how to make your site mobile friendly? My weblog looks weird when browsing from my iphone4. I’m trying to find a template or plugin that might be able to resolve this problem.
    If you have any suggestions, please share. Appreciate it!

  12. black friday deals November 22, 2012 at 5:54 pm

    If you would like to get a good deal from this article then you have to apply such techniques to your won webpage.

  13. November 22, 2012 at 5:55 pm

    Howdy just wanted to give you a quick heads up. The text
    in your article seem to be running off the screen in Internet explorer.
    I’m not sure if this is a format issue or something to do with web browser compatibility but I figured I’d post
    to let you know. The design and style look great though!
    Hope you get the issue fixed soon. Kudos

  14. financial aid July 14, 2013 at 1:35 pm

    Hi to all, how is the whole thing, I think every one is getting more
    from this website, and your views are fastidious
    in support of new visitors.

  15. fernsehsessel aufstehhilfe August 4, 2013 at 10:03 pm

    I drop a leave a response when I like a post on
    a website or if I have something to valuable to contribute to the conversation.

    Usually it’s triggered by the passion displayed in the post I looked at. And on this post Curb Gem – Libcurl bindings for Ruby | Sarav’s Weblog.
    I was actually moved enough to create a comment ๐Ÿ˜› I do have
    a few questions for you if it’s okay. Is it only me or do some of the remarks come across like written by brain dead folks? ๐Ÿ˜› And, if you are writing at additional online social sites, I’d like to follow you.
    Could you list all of your communal pages like your twitter feed, Facebook page or linkedin profile?

  16. skin care tips for t zone January 18, 2014 at 8:49 pm

    Post writing is also a fun, if you know after that you can write otherwise it is complicated to write.

  17. March 7, 2014 at 1:52 am

    If you plan to be a book heroine, this means that you must eat all the time, except
    when youโ€™re not eating, and then you should be thinking about eating.
    Celebrity impersonations, musical gags, and the
    use of props are just some of the things that you could do in your routine.
    He hosted Comedy Central’s’The Man Show’ as well as the ubiquitous pseudo-porn for the sexually crippled, ‘Girls Gone Wild’, both solely and shamelessly for financial

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: