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. Advertisements

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. Fox

    post_form

    Fox, Feb 14, 2006, in forum: Ruby
    Replies:
    1
    Views:
    202
    David Vallner
    Feb 14, 2006
  2. Dan Tenenbaum
    Replies:
    5
    Views:
    394
  3. |MKSM|

    Net::HTML#post_form with ASP

    |MKSM|, Mar 14, 2006, in forum: Ruby
    Replies:
    4
    Views:
    225
    carlos tirado
    Mar 15, 2006
  4. Joe
    Replies:
    5
    Views:
    344
    Jano Svitok
    Sep 21, 2007
  5. Arie Kusuma Atmaja
    Replies:
    0
    Views:
    208
    Arie Kusuma Atmaja
    Sep 4, 2006
  6. Coosa Aa

    post_form

    Coosa Aa, Mar 8, 2007, in forum: Ruby
    Replies:
    11
    Views:
    330
    Coosa Aa
    Mar 11, 2007
  7. coosa

    Net::HTTP.post_form issue

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