# How do I post to a form (http) in Ruby 1.8.2?

**URL:** <https://www.ruby-forum.com/t/how-do-i-post-to-a-form-http-in-ruby-1-8-2/54732>\
**Category:** Ruby\
**Created:** [March 13, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/how-do-i-post-to-a-form-http-in-ruby-1-8-2/54732 "2006-03-13T20:39:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [March 13, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/how-do-i-post-to-a-form-http-in-ruby-1-8-2/54732/1 "2006-03-13T20:39:43Z")

</div>

Hi all,

How do I do the equivalent of Net::HTTP.post\_form() in Ruby 1.8.2? (This  
method was not implemented until 1.8.3).

This might seem like a strange question but bear with me.

Though our production server is running Ruby 1.8.4, our development  
machines are Macs using Locomotive (which is a self-contained Ruby/Rails  
environment). I have been told by one of the lead Locomotive developers  
that it is virtually impossible to upgrade the version of Ruby inside  
Locomotive, that I should wait for the next version which will use a  
more current version of Ruby.

So my question is, until then, how would I make the following code  
fragment, which works in 1.8.3+, work in 1.8.2?

require ‘net/http’  
require ‘uri’

parms = {:client=\>“safari”, :rls=\>“en”, :q =\> “myquery”,  
:ie =\> “UTF-8”, :oe =\> “UTF-8”}  
url = “[Google](http://www.google.com/search)”

res = Net::HTTP.post\_form(URI.parse(url), parms)

print res.body  
print

(By “work”, I mean, getting something back from the server–in this  
particular case the server may return an error, but at least the post  
succeeded.)

It has been suggested that I extend Ruby to implement this method. I  
gave that a try and it didn’t seem too easy, as post\_form in turn  
depends on other methods that don’t exist in 1.8.2. But I am a total  
newbie at extending Ruby so it could be I missed something

I couldn’t get the examples of request\_post to work either.

At this point I don’t care what approach I use, I just want to be able  
to post to a form on an http server in Ruby 1.8.2. Any idea what would  
be the quickest way to do that?  
Thanks
