[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Sending a cookie in the request using Net::HTTP

Francis Hwang

12/4/2004 5:07:00 PM

I can't find this answered in the RDoc, so I'll ask here: How do I send
the cookie string in an HTTP request using Net::HTTP? I tried doing
something like:

Net::HTTP.start( 'server.host.here' ) { |http|
response = http.get(
'/local/file.rb',
'Cookie: cookie_name=cookie_val'
)
}

hoping that the "initheader" in HTTP#get is where I should drop the
cookie value, but that just gave me a traceback.

Francis Hwang
http://f...



2 Answers

Jos Backus

12/4/2004 10:16:00 PM

0

On Sun, Dec 05, 2004 at 02:07:17AM +0900, Francis Hwang wrote:
> I can't find this answered in the RDoc, so I'll ask here: How do I send
> the cookie string in an HTTP request using Net::HTTP? I tried doing
> something like:
>
> Net::HTTP.start( 'server.host.here' ) { |http|
> response = http.get(
> '/local/file.rb',

Try passing any extra headers in a hash here, like this:

{"Cookie" => 'cookie_name=cookie_val; another_cookie=brownie'}

> 'Cookie: cookie_name=cookie_val'
> )
> }

--
Jos Backus _/ _/_/_/ Sunnyvale, CA
_/ _/ _/
_/ _/_/_/
_/ _/ _/ _/
jos at catnook.com _/_/ _/_/_/ require 'std/disclaimer'


Francis Hwang

12/5/2004 12:27:00 AM

0

Works like a charm. Thanks!

On Dec 4, 2004, at 5:15 PM, Jos Backus wrote:

> On Sun, Dec 05, 2004 at 02:07:17AM +0900, Francis Hwang wrote:
>> I can't find this answered in the RDoc, so I'll ask here: How do I
>> send
>> the cookie string in an HTTP request using Net::HTTP? I tried doing
>> something like:
>>
>> Net::HTTP.start( 'server.host.here' ) { |http|
>> response = http.get(
>> '/local/file.rb',
>
> Try passing any extra headers in a hash here, like this:
>
> {"Cookie" => 'cookie_name=cookie_val; another_cookie=brownie'}
>
>> 'Cookie: cookie_name=cookie_val'
>> )
>> }
>
> --
> Jos Backus _/ _/_/_/ Sunnyvale, CA
> _/ _/ _/
> _/ _/_/_/
> _/ _/ _/ _/
> jos at catnook.com _/_/ _/_/_/ require
> 'std/disclaimer'
>
>

Francis Hwang
http://f...