Generating http post in Ruby

Hi, I'm in need to send a file throught an http post and examine the response within a Rails project. Net::HTTP is powerful but way too hard to use, I'm in need of something slick and quick to use and manage.

Actually I've found Curb, which works like a charm ( http://rubyforge.org/projects/curb ) but it has a big problem: it depends on external libraries (curlib) and doesn't work at all on win (which is the platform used by most of our team).

What would really be a great tool is an high level libraries which relies on Net::HTTP o similar, which allows me to achieve my results with really compact statements.

Curb is really smart at this:

    c = Curl::Easy.new post_url     c.multipart_form_post = true     c.http_post(       Curl::PostField.content('some_var_name', some_var_value),       Curl::PostField.file('file_name', incomming_file.path)     )     puts c.body_str if c.response_code == 200

Is there any other similar library that can work on multiple platforms

Hi Jules,

Ashkey wrote:

Hi, I'm in need to send a file throught an http post and examine the response within a Rails project. Net::HTTP is powerful but way too hard to use, I'm in need of something slick and quick to use and manage.

I'm not sure I understand you completely. What is it that the send_file or send_data methods (api.rubyonrails.org) don't do that you need?

Best regards, Bill

That doesn't look much easier than Net::HTTP.

  my_form_data = {:title => 'Example', :body => 'Content'}

  res = Net::HTTP.post_form(     URI.parse('http://www.example.com/recipient/'),     my_form_data)

        puts res.response.body if res.response.code == 200

What is it about Curl that you prefer?

James.