[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Net::HTTP#post_form - setting user agent, referrer?

Igor France

3/30/2006 3:19:00 AM

How can I set the user-agent and HTTP_REFERER (and perhaps other vars)
when using Net::HTTP's post_form method?

Thanks,
Joe

--
Posted via http://www.ruby-....


5 Answers

Marc Soda

3/30/2006 3:28:00 AM

0

You can't. Use HTTP#request_post(path, data, headers) where headers is a hash.

Marc

On 3/29/06, Joe <joe@yahoo.com> wrote:
> How can I set the user-agent and HTTP_REFERER (and perhaps other vars)
> when using Net::HTTP's post_form method?
>
> Thanks,
> Joe
>
> --
> Posted via http://www.ruby-....
>
>


Igor France

3/31/2006 2:56:00 AM

0

Thanks. Anybody know how the headers are specified? I can't find any
documentation that spells it out. Is it...

headers = {
'Referer' => 'http://xy...,
'User-Agent' => 'mozillia'
}

Or...

headers = {
'HTTP_REFERER' => 'http://xy...,
'HTTP_USER_AGENT' => 'mozillia'
}


Thanks,
Joe

--
Posted via http://www.ruby-....


Adam Keys

3/31/2006 4:38:00 PM

0

On Mar 30, 2006, at 8:55 PM, Joe wrote:
> Thanks. Anybody know how the headers are specified? I can't find any
> documentation that spells it out. Is it...
>
> headers = {
> 'Referer' => 'http://xy...,
> 'User-Agent' => 'mozillia'
> }
>

I believe this is the standard form.

--
~akk
http://there...




Asit Katiyar

9/21/2007 1:04:00 PM

0

Adam Keys wrote:
> On Mar 30, 2006, at 8:55 PM, Joe wrote:
>> Thanks. Anybody know how the headers are specified? I can't find any
>> documentation that spells it out. Is it...
>>
>> headers = {
>> 'Referer' => 'http://xy...,
>> 'User-Agent' => 'mozillia'
>> }
>>
>
> I believe this is the standard form.

Hi,
I am also facing the same kind of problem. I tried with the solution
given in this thread, but couldn't succeeded.
When I try this:

response = NET::HTTP.request_post(url,post_args, headers)

I get the error:

undefined method `request_post' for Net::HTTP:Class

and when I try:

response = http.request_post(url,post_args, headers)

the error was:

undefined local variable or method `http' for Yahoo:Class

Please help me

Thanks



--
Posted via http://www.ruby-....

Jano Svitok

9/21/2007 1:34:00 PM

0

On 9/21/07, Asit Katiyar <asitkatiyar@yahoo.com> wrote:
> Hi,
> I am also facing the same kind of problem. I tried with the solution
> given in this thread, but couldn't succeeded.
> When I try this:
>
> response = NET::HTTP.request_post(url,post_args, headers)
>
> I get the error:
>
> undefined method `request_post' for Net::HTTP:Class
>
> and when I try:
>
> response = http.request_post(url,post_args, headers)
>
> the error was:
>
> undefined local variable or method `http' for Yahoo:Class

You're mixing class and instance methods. Either use HTTP.post_form()
or create an instance of HTTP with HTTP.new or HTTP.start and then use
http.post or http.post_request.

Jano