# Advice for Net::HTTP class

**URL:** <https://www.ruby-forum.com/t/advice-for-net-http-class/65821>\
**Category:** Ruby\
**Created:** [August 21, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/advice-for-net-http-class/65821 "2006-08-21T18:15:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmihelac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@bmihelac](https://www.ruby-forum.com/u/bmihelac)\
**Post date:** [August 21, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/advice-for-net-http-class/65821/1 "2006-08-21T18:15:53Z")

</div>

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](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 M.

---

<div class="post-metadata">

**Author:** ![bmihelac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@bmihelac](https://www.ruby-forum.com/u/bmihelac)\
**Post date:** [August 22, 2006, 8:25am UTC](https://www.ruby-forum.com/t/advice-for-net-http-class/65821/2 "2006-08-22T08:25:19Z")

</div>

Bojan M. wrote:

> response = Net::HTTP.start(‘localhost’, 80) { |http|  
> 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 M.

thnx Mike L. for solution:

headers[‘content-type’] = ‘application/x-www-form-urlencoded’ if method  
==‘POST’  
http.post(’/p.php’, ‘query=123ruby’, headers)
