cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Relation between CURLOPT_SHARE and cookie handling

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 13 Nov 2003 20:39:08 +0100 (CET)

On Thu, 13 Nov 2003, Siddhartha Prakash Jain wrote:

> curl_easy_setopt(curlhandle, CURLOPT_SHARE, m_Curlshare);

> The last call results in data->cookies being initialised. And this results
> in curl parsing cookies and setting them.

I consider that unconditional cookie initialization a bug. We should do
something about it!

> And while we are sending more requests in http.c Curl_http(), when we do the
> following things: First we do check if someone has already set Cookie header
> even if data->set.cookie might be true.

> if(data->set.cookie && !checkheaders(data, "Cookie:")) {
> if(conn->allocptr.cookie)
> free(conn->allocptr.cookie);
> conn->allocptr.cookie = aprintf("Cookie: %s\015\012", data->set.cookie);
> }

Right. This is kind of weird, and only makes sure that if you provide a
Cookie: custom header it will override the cookies you set with
CURLOPT_COOKIE. I'm not sure this logic make sense in very many situations.

> if(data->cookies) {
> co = Curl_cookie_getlist(data->cookies,

 ...

> But this time we don't check using checkheaders?
> Why is that?

Since the cookie(s) must've arrived to us on purpose and if told to use
cookies we include those that match.

> My problem is that because I am setting the cookie header explicitly outside
> of curl and still want to use the share option, how do I stop curl from
> automatically sending cookies? Most of the sites don't mind duplicate
> cookies being sent in the same request but some don't work.

I think we should fix the CURLOPT_SHARE code initializing the cookie stuff
like that. Wouldn't that be fine enough with you too?

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
 [[ Do not post private mails to this email address. They won't reach me. ]]
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
Received on 2003-11-13