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 ...
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 ...
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:
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.
Yes, you really want to use http-access2, it does more of the heavy
lifting for you.
···
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 ...