# Net::HTTP and post\_form

**URL:** <https://www.ruby-forum.com/t/net-http-and-post-form/143723>\
**Category:** Ruby\
**Created:** [July 22, 2008, 8:35am UTC](https://www.ruby-forum.com/t/net-http-and-post-form/143723 "2008-07-22T08:35:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@Joel\_VanderWerf](https://www.ruby-forum.com/u/Joel_VanderWerf)\
**Post date:** [July 22, 2008, 8:35am UTC](https://www.ruby-forum.com/t/net-http-and-post-form/143723/1 "2008-07-22T08:35:05Z")

</div>

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.
