Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Advice for Net::HTTP class
Bojan Mihelac
8/21/2006 4:13:00 PM
Hello,
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
--
Bojan Mihelac
Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com
-> tools, scripts, tricks from our code lab:
http://source.m...
1 Answer
Bojan Mihelac
8/22/2006 6:24:00 AM
0
Bojan Mihelac wrote:
> Hello,
> 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
>
>
>
>
thnx Mike L. for solution:
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.m...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Advice for Net::HTTP class
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password