W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2003

RE: cookie handling

From: Sinha, Raj (Raj) <rajsinha@avaya.com>
Date: Mon, 21 Jul 2003 09:59:10 -0400
Message-ID: <8CA1128D59AD27429985B397118CEDDF019E312A@nj7460avexu1.global.avaya.com>
To: "Richard Atterer" <richard@list03.atterer.net>, <www-lib@w3.org>

Hi Richard thanks for responding..

I think I may have a solution for both of my problems... But don't have a explanation as to why one works not the other...


For the etag I have the trace on for mime headers I see that the client receives a Etag header. 

However if I try to use HTResponse_etag(response) I get a NULL value. But the following code works

HTParentAnchor * anchor = HTRequest_anchor(request);
HTAssocList * headers = HTAnchor_header(anchor);
printf("TheAnchor HTAnchor_etag |%s| \n", HTAnchor_etag(anchor));

Any thoughts on that. I am not sure why the HTResponse_etag fails.


Second on the cookie handling I looked at the cookie example. I borrowed the code and saw that the after handler was being called but nothing happened. After some digging I saw in HTCookie.c the following snippet

/* What should we do with cookies? */
PRIVATE HTCookieMode CookieMode = HT_COOKIE_PROMPT | HT_COOKIE_ACCEPT | HT_COOKIE_SEND;

But since I had no handlers for a Prompt kind of alert the cookie handler just didn't do anything.

I removed the HT_COOKIE_PROMPT  and basically just use HT_COOKIE_ACCEPT | HT_COOKIE_SEND for cookie handling.

Am I on the right track here.

Thanks

raj

Raj Sinha
 


-----Original Message-----
From: Richard Atterer [mailto:richard@list03.atterer.net] 
Sent: Sunday, July 20, 2003 11:24 AM
To: www-lib@w3.org
Subject: Re: cookie handling



Hello Raj,

On Thu, Jul 17, 2003 at 10:39:26AM -0400, Sinha, Raj (Raj) wrote:
> I am trying to parse the HTTP header.. Actually more interested in 
> getting the Etag header.
> 
> I have tried using the func HTResponse_etag(response) in terminate 
> handler but cannot get the etag value (returns Null). I verify that 
> the correct response object is being passed. Am I on the right track

Hm, I think so! Have you enabled libwww's logging? This may help you to 
find out whether the server sent an etag header and what libwww thought of 
it:

  HTSetTraceMessageMask("flbtspuhox");
  HTTrace_setCallback(tracer);
    
On Sun, Jul 20, 2003 at 07:03:03AM -0400, Sinha, Raj (Raj) wrote:
> Can anyone please illustrate to me with code cookie handling 
> behavior... An example of storage would be appreciated o get me 
> started.. I seem to be going in circles

I have never used libwww's cookies before, but from a look at the docs the following might be the way it works:

- Init other parts of libwww
- HTCookie_init()
- HTCookie_setCallbacks(setCookie, 0, findCookie, 0)
- .....Create and run HTRequests.....
- HTCookie_deleteCallbacks()
- HTCookie_terminate()

Now you need to write the two functions, setCookie() and findCookie(). The first one looks at the cookie it is given and writes its data to a file (or caches it in memory, whatever), possibly replacing an older version of the same cookie.

The second one is given just a request and then needs to figure out which cookies to send along with that request; it returns the list of cookies (I guess). Typically, finding the cookies to send will involve looking at the request's URL and scanning through the cookie file (or whatever) for cookies with the same domain as the request. A complete implementation will also remove cookies from the cookie file when they have expired (that is, HTCookie_expiration()>time(NULL), at a guess).

Maybe have a look at the cookie "standard" at <http://home.netscape.com/newsref/std/cookie_spec.html>

HTH,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/|  http://atterer.net  |  0x888354F7
   '` 
Received on Monday, 21 July 2003 09:59:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:43 GMT