How to POST HEADERS along with COOKIES

Discussion in 'Ruby' started by Daun Jaun, Nov 11, 2004.

  1. Daun Jaun

    Daun Jaun Guest

    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
     
    Daun Jaun, Nov 11, 2004
    #1
    1. Advertising

  2. On Thu, 11 Nov 2004 15:55:16 +0900, Daun Jaun <> 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/http-access2/
    --
    i'm not flying. i'm falling... in style.
     
    Edwin Eyan Moragas, Nov 11, 2004
    #2
    1. Advertising

  3. Daun Jaun <> wrote in
    news::

    > 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_spec.html

    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
     
    Kaspar Schiess, Nov 11, 2004
    #3
  4. Daun Jaun

    Eric Hodel Guest

    --6FinHCQBQ0zFDOqT
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Edwin Eyan Moragas () wrote:

    > On Thu, 11 Nov 2004 15:55:16 +0900, Daun Jaun <> wro=

    te:
    > > Hi
    > > can any one please tell me how to post cookies; shud it be placed in th=

    e header
    > > and if so in what format;
    > >=20
    > > ckyArr =3D ... # suppose i have an array of CGI::Cookie objects
    > >=20
    > > hdr['cookie']=3D unKnownFunc( ckyArr )
    > >=20
    > > h=3DNet::HTTP.new( ... )
    > >=20
    > > resp,body =3D 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
    > >=20
    > > To make this work what shud be unKnownFunc ..?
    > >=20
    > > Please some one help ; my whole project depends on this primarily ... ;=

    -)
    >=20
    > http://raa.ruby-lang.org/project/http-access2/


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

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


    --6FinHCQBQ0zFDOqT
    Content-Type: application/pgp-signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (FreeBSD)

    iD8DBQFBk6/oMypVHHlsnwQRAj74AJoDJTGi1bN1Ib5JTUQamOzws/WrqACg+WEL
    tYn6DyIfwxzfo/Mvk4safqA=
    =iI3d
    -----END PGP SIGNATURE-----

    --6FinHCQBQ0zFDOqT--
     
    Eric Hodel, Nov 11, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Antony

    cookies in HTTP POST headers

    Antony, Feb 1, 2005, in forum: HTML
    Replies:
    1
    Views:
    543
    Toby Inkster
    Feb 2, 2005
  2. dont bother
    Replies:
    0
    Views:
    803
    dont bother
    Mar 3, 2004
  3. _Who
    Replies:
    7
    Views:
    2,679
  4. Phil
    Replies:
    4
    Views:
    679
    Gabriel Genellina
    Jan 17, 2010
  5. Ian
    Replies:
    2
    Views:
    1,958
Loading...

Share This Page