[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

How to POST HEADERS along with COOKIES

Daun Jaun

11/11/2004 6:55:00 AM

Hi
can any one please tell me how to post cookies; shud it be placed in the header
and if so in what format;

ckyArr = ... # suppose i have an array of CGI::Cookie objects

hdr['cookie']= unKnownFunc( ckyArr )

h=Net::HTTP.new( ... )

resp,body = h.post( path, query, hdr )
# path has a program that expects cookies
# if cookies are not present or not in desired format it gives
# paramter format error : and access is denied

To make this work what shud be unKnownFunc ..?

Please some one help ; my whole project depends on this primarily ... ;-)

Awaiting replies
Daun Jaun


4 Answers

Edwin Eyan Moragas

11/11/2004 7:10:00 AM

0

On Thu, 11 Nov 2004 15:55:16 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> Hi
> can any one please tell me how to post cookies; shud it be placed in the header
> and if so in what format;
>
> ckyArr = ... # suppose i have an array of CGI::Cookie objects
>
> hdr['cookie']= unKnownFunc( ckyArr )
>
> h=Net::HTTP.new( ... )
>
> resp,body = h.post( path, query, hdr )
> # path has a program that expects cookies
> # if cookies are not present or not in desired format it gives
> # paramter format error : and access is denied
>
> To make this work what shud be unKnownFunc ..?
>
> Please some one help ; my whole project depends on this primarily ... ;-)

http://raa.ruby-lang.org/project/htt...
--
i'm not flying. i'm falling... in style.


Kaspar Schiess

11/11/2004 10:29:00 AM

0

Daun Jaun <compsci.isi@gmail.com> wrote in
news:dbd0bb6c041110225520095195@mail.gmail.com:

> ckyArr = ... # suppose i have an array of CGI::Cookie objects
> hdr['cookie']= unKnownFunc( ckyArr )
> h=Net::HTTP.new( ... )

Quoting from: http://wp.netscape.com/newsref/std/cookie...

Syntax of the Cookie HTTP Request Header
When requesting a URL from an HTTP server, the browser will match the
URL against all cookies and if any of them match, a line containing
the name/value pairs of all matching cookies will be included in the
HTTP request. Here is the format of that line:

Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ...

Considering the output of CGI::Cookie to be almost, but not quite what
you are looking for, I would suggest keeping your cookies in a hash of
string => string
instead. Given such a hash:
a = { 'foo' => "This is a test ;", 'bar' => 'Cookie value' }
you could then format everything to the left of 'Cookie: ' by doing
a.collect { |k, v| "#{k}=#{ CGI.escape(v) };" }.join(' ')$
resulting in
"foo=This+is+a+test+%3B; bar=Cookie+value;"

The encoding of the cookie value is not covered by the above link; it is
only to be considered as a rough introduction. There is a rfc (whose
number I don't have in my head) that describes what CGI.escape does.

I hope that gets you on track.

kaspar

hand manufactured code - www.tua.ch/ruby



Eric Hodel

11/11/2004 6:31:00 PM

0

Edwin Eyan Moragas (haaktu@gmail.com) wrote:

> On Thu, 11 Nov 2004 15:55:16 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> > Hi
> > can any one please tell me how to post cookies; shud it be placed in the header
> > and if so in what format;
> >
> > ckyArr = ... # suppose i have an array of CGI::Cookie objects
> >
> > hdr['cookie']= unKnownFunc( ckyArr )
> >
> > h=Net::HTTP.new( ... )
> >
> > resp,body = h.post( path, query, hdr )
> > # path has a program that expects cookies
> > # if cookies are not present or not in desired format it gives
> > # paramter format error : and access is denied
> >
> > To make this work what shud be unKnownFunc ..?
> >
> > Please some one help ; my whole project depends on this primarily ... ;-)
>
> http://raa.ruby-lang.org/project/htt...

Yes, you really want to use http-access2, it does more of the heavy
lifting for you.

--
Eric Hodel - drbrain@segment7.net - http://se...
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

who

10/14/2010 5:37:00 PM

0

tuna <tuna2@nz11.com> wrote:

> Cái Mã t? th?ng whocares nhá
>
> Mày muo^'n th?ng cha mày mút c? sâm c?a tao thì tao s?n sàng
> anytime !!!
> ??ng có "ném ?á dâ'u tay"
>
> Cha m? mày c?ng m?t m?t vì r?n ra mày ??y !!!
>
> tao

Chi. "Tu' Na." tha^n thu+o+ng, ngu+o+`i vi.t mi`nh co' ca^u "a(n ro^`i
ha~y no'i" ngu+o+`i Ta^y Phu+o+ng co' ca^u "do^ng too'c guy't gio mao pho^`
dda^m mi"

Vi` ti`ng ddo^`ng hu+o+ng tui cu~ng khuye^n chi. ne^n nha? cu.c nha^n sa^m
ra ro^`i ha~y no'i.

Chi. ngu la('m ne^n chu+?i ma` kho^ng gia?ng thi` chi? kho^ng hie^?u, va`
vo+'i ba?n ti'nh he`n ha. lu'm khu'm cu?a chi. thi` co' hie^?u c~ung cha(?ng
la` bao. DDa.i kha'i la` khui ra ca'i ba^?n cu?a chi. thi` chi. nga^.m ca^m
kho^ng da'm no'i, ro^`i ddi mang nhu+~ng ca'i link cu?a ngu+o+`i kha'c no'i.
Ngu dde^'n the^' thi` chi? xuo^'t ddo+`i nga^.m sa^m anh "Ma`i Dao" va`
luo^.c su+ Qua'c DDa.i Bi.p tho^i

> ==============
>
> On Oct 13, 4:52 pm, w...@cares.net wrote:
> > tuna <tu...@nz11.com> wrote:
> > > Ma^'y ngu+o+`i kho^ng thi'ch "chi'nh chi. chi'nh em" thi` ba^y gio+`
> > > no' theo sau lu+ng mo+'i tha^'y khie^'p !!!
> >
> >         Chi. "Tu' Na." tha^n thu+o+ng, tui tha^'y chi. cu~ng chi.u kho' ddi
> > lu+o+.m ba'o dde^? che^ khie^'p, nhu+ng la.i cho+i tro` "ne'm dda' da^'u
> > tay" ddo^? lo^~i cho ngu+o+`i kha'c.
> >
> >         Thi' du. nhu+ khi anh xa "Ma`i Dao" tha'c ma'c da` tu+. ho?i ra(`ng thi`
> > ma` na` ta.i sao ma'i ta'nh nai kho^ng co' "tu` ti" ma` em na.i co' nghe'n,
> > thi` chi. na.i ta'nh to^.i tu+. ta? no+`i ra(`ng thi` ma` na` "anh cu~ng
> > bie^'t la` 1 mi`nh em thi` la`m sao ma` co' mang ddu+o+.c .... cu~ng ta.i
> > tha(`ng luo^.c su+. Qua'c DDa.i Bi.p no' nhe't cu? nha^n sa^m va`o bu.ng em
> > ..."