Hello,
I noticed that curl_easy_duphandle does not necessarily duplicates the
CURLOPT_COOKIEFILE option. It only enables the cookie engine in the
destination handle if data->cookies is not NULL (where data is the
source handle). In case of a new initialized handle which just had the
cookie support enabled by a curl_easy_setopt(handle, CURL_COOKIEFILE,
"")-call, handle->cookies is still NULL because the setopt-call only
appends the value to data->change.cookielist, hence duplicating this
handle will not have the cookie engine switched on. Attached is a patch
against version 7.19.4 which will additionally duplicate
data->change.cookielist if not NULL.
Ciao, Frank
*** easy.c.orig 2009-01-29 21:41:51.000000000 +0100
--- easy.c 2009-03-06 23:31:45.000000000 +0100
*************** CURL *curl_easy_duphandle(CURL *incurl)
*** 642,655 ****
--- 642,678 ----
data->set.cookiesession);
if(!outcurl->cookies) {
break;
}
}
+
#endif /* CURL_DISABLE_HTTP */
/* duplicate all values in 'change' */
+ #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
+ if(data->change.cookielist) {
+ struct curl_slist *cl_src = data->change.cookielist;
+ struct curl_slist *cl_dest;
+ bool breakout = 0;
+
+ while(cl_src) {
+ cl_dest = curl_slist_append(outcurl->change.cookielist, cl_src->data);
+
+ if (!cl_dest) {
+ breakout = 1;
+ break;
+ }
+
+ outcurl->change.cookielist = cl_dest;
+ cl_src = cl_src->next;
+ }
+ if (breakout)
+ break;
+ }
+ #endif /* CURL_DISABLE_HTTP */
+
if(data->change.url) {
outcurl->change.url = strdup(data->change.url);
if(!outcurl->change.url)
break;
outcurl->change.url_alloc = TRUE;
*************** CURL *curl_easy_duphandle(CURL *incurl)
*** 690,699 ****
--- 713,726 ----
if(outcurl->state.connc &&
(outcurl->state.connc->type == CONNCACHE_PRIVATE))
Curl_rm_connc(outcurl->state.connc);
if(outcurl->state.headerbuff)
free(outcurl->state.headerbuff);
+ #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
+ if (outcurl->change.cookielist)
+ curl_slist_free_all(outcurl->change.cookielist);
+ #endif
if(outcurl->change.url)
free(outcurl->change.url);
if(outcurl->change.referer)
free(outcurl->change.referer);
Curl_freeset(outcurl);