Net::HTTP and post_form

Discussion in 'Ruby' started by Joel VanderWerf, Jul 22, 2008.

  1. I expected this to work (since the #post_form method is documented), but
    the method is not found:

    require 'net/http'

    Net::HTTP.start('127.0.0.1', 4567) do |http|
    http.post_form('/foo', "bar" => "baz")
    end

    Here's the error:

    http-post-bug.rb:4: undefined method `post_form' for #<Net::HTTP
    127.0.0.1:4567 open=false> (NoMethodError)
    from /usr/local/lib/ruby/1.8/net/http.rb:543:in `start'
    from /usr/local/lib/ruby/1.8/net/http.rb:440:in `start'
    from http-post-bug.rb:3


    Why isn't post_form usable in the block form? I'm using the block form
    because it's actually going thru a proxy.

    I can do it myself by creating the request manually:

    req = Net::HTTP::post.new(path)
    req.form_data = params
    Net::HTTP.new('127.0.0.1', 4567).start {|http|
    http.request(req)
    }

    but it's kind of disappointing.

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
    Joel VanderWerf, Jul 22, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Tenenbaum
    Replies:
    5
    Views:
    217
  2. Joe
    Replies:
    5
    Views:
    201
    Jano Svitok
    Sep 21, 2007
  3. Arie Kusuma Atmaja
    Replies:
    0
    Views:
    108
    Arie Kusuma Atmaja
    Sep 4, 2006
  4. coosa

    Net::HTTP.post_form issue

    coosa, Mar 8, 2007, in forum: Ruby
    Replies:
    1
    Views:
    116
    coosa
    Mar 8, 2007
  5. Ak 756
    Replies:
    5
    Views:
    197
    Chris Carter
    Aug 15, 2007
Loading...

Share This Page