How to generate this request with NET::HTTP

Hi,

Whith NET::HTTP.post_form how can I generate the next request?

POST /script.php?op=publish HTTP/1.1

ch=0&cnt=something


When I use:
res =
Net::HTTP.post_form(URI.parse(‘http://www.xxx.com/script.php?op=publish’),
{“ch” => 0, “cnt” => “something”})

http://www.xxx.com/script.php?op=publish
ch0cntsomething

There are no = and & so I think that fails on the php script…

Thanks

Hi, any hints anyone?

Thanks.

On Sep 21, 11:06 pm, Pod C. [email protected]
wrote:

When I use:
res =
Net::HTTP.post_form(URI.parse(‘http://www.xxx.com/script.php?op=publish’),
{“ch” => 0, “cnt” => “something”})

http://www.xxx.com/script.php?op=publish
ch0cntsomething

There are no = and & so I think that fails on the php script…

That should work. What makes you think the & and = are missing ? Have
you looked at the data going over the wire ?

Fred

I was using puts to check it but I’m not sure I doing it correctly.

How can I see the generated request before it is sent by post_form?
I can’t seem to catch it with the Fiddler tool.

Thanks.

On 22 Sep 2008, at 09:41, Pod C. wrote:

I was using puts to check it but I’m not sure I doing it correctly.

That wouldn’t do much - it probably just called puts on the hash, and
push for hashes isn’t very useful.

How can I see the generated request before it is sent by post_form?

I don’t think you can (unless you use the rather more verbose forms of
the Net::HTTP api)

I can’t seem to catch it with the Fiddler tool.

I would have tried tcpdump, ethereal etc… What does the data look
like when it appears at the php script (or do you no control that)

Fred

Thanks again Fred. I used Ethereal now. And yes the arguments are there
correctly!

What I found is that the next line:
Net::HTTP.post_form(URI.parse(‘http://www.something.com/script.php?op=publish’),
{“ch” => 0, “cnt” => “something”})

Produces:

POST http://www.something.com/script.php HTTP/1.1
Accept: /
Content-Type: application/x-www-form-urlencoded
Content-Length: 14
Host: www.something.com

ch=0&cnt=sometext

So it leaves out the ?op=publish from the url
I need to look into that now.

Thanks for your suggestions!

Hi,

Here’s how I got the thing working:

http = Net::HTTP.new(‘www.something.com’)
resp = http.post(’/script.php?op=publish’, ‘ch=0&cnt=something’)

Regards