cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: cookie interface suggestion

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 19 Jun 2003 08:53:00 +0200 (CEST)

On Thu, 19 Jun 2003, Bo Lorentsen wrote:

> So how about having two functions (or the same with propper params), one
> that gets called (if set) when reciving a new cookie, and one getting
> called when curl is looking for one. If the function are not given, curl
> defauts to the current API.
>
> By doing this I can bypass the internal structure totally, and maintain
> cookies by my own means. And too me this looks like the same philosophy as
> the with streams in curl.
>
> The only problem then would be the life span of the cookie ellements.

That's truly an idea I like. See below for my suggested approach on this.

The life span problem would be a subject for the external cookie handler to
take care of, libcurl will then just ask the app for what cookies to pass to
a given site, and only non-expired cookies should be in that list...

So, my suggestion gets extended by this:

 SENDFUNC - set a function pointer that is called by libcurl each time a HTTP
        request (that can return a set of cookies for libcurl to use in this
        request) is about to be sent over the network by libcurl, the
        function should match this prototype:

        struct curl_cookie_request {
          char *host;
          char *path;
          bool secure;
        };

        int sendfunc(CURL *handle,
                     struct curl_cookie_request *reqdata,
                     struct curl_slist **list,
                     void *senddata);

        The callback function shall create a curl_slist of cookies in the
        format "name=value" and then make the '*list' pointer points to the
        first element, or make it point to NULL if no cookies are to be sent.

        By returning 1 from the callback, libcurl will not attempt to use any
        of its own internal set of cookies. Returning 0 will make libcurl
        proceed as normal. (Other return-codes are considered reserved for
        future use.)

 SENDDATA - set whatever userdata you want the SENDFUNC callback to receive
        in its senddata argument.

-- 
 Daniel Stenberg -- curl: been grokking URLs since 1998
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
Received on 2003-06-19