Bojan Mihelac wrote:> Hi,
> sorry for duplicating these question from ruby-talk, thought someone
> from Rails list can help me.
>
> I am loosing myself with Net:HTTP class, following
> HowToRenderProxiedPages article I cannot make post method to proxy
> parameters to web page.
>
>
> require ''net/http''
> ### p.php <?php print_r($_POST)?>
>
> ### 1. does not work
> response = Net::HTTP.start(''localhost'', 80) { |http|
> http.post(''/p.php'', ''query=ruby'')
> }
> puts response
>
> ### 2. works
> response =
Net::HTTP.post_form(URI.parse(''http://localhost/p.php''), {
> "query" => "ruby"})
> puts response
>
>
> Can anyone please explain me why the first one doesn''t work? (I am
using
> Ruby 1.8.4, tested both linux and win)
>
> thanx,
> Bojan Mihelac
>
>
>
>
Found reason, header was not set in 1# case:
headers[''content-type''] =
''application/x-www-form-urlencoded'' if method
==''POST''
http.post(''/p.php'', ''query=123ruby'',
headers)
--
Bojan Mihelac
Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com
-> tools, scripts, tricks from our code lab: http://source.mihelac.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---