Michael Wallner made the CULROPT_COOKIELIST option support a new magic

string: "FLUSH". Using that will cause libcurl to flush its cookies to the
CURLOPT_COOKIEJAR file.
This commit is contained in:
Daniel Stenberg 2007-10-05 14:37:33 +00:00
Родитель bffa835573
Коммит 4449bd9b4d
4 изменённых файлов: 49 добавлений и 27 удалений

Просмотреть файл

@ -7,6 +7,10 @@
Changelog Changelog
Daniel S (5 October 2007) Daniel S (5 October 2007)
- Michael Wallner made the CULROPT_COOKIELIST option support a new magic
string: "FLUSH". Using that will cause libcurl to flush its cookies to the
CURLOPT_COOKIEJAR file.
- The new file docs/libcurl/ABI describes how we view ABI breakages, soname - The new file docs/libcurl/ABI describes how we view ABI breakages, soname
bumps and what the version number's significance to all that is. bumps and what the version number's significance to all that is.
@ -25,7 +29,6 @@ Yang Tse (3 October 2007)
- Fixed issue related with the use of ares_timeout() result. - Fixed issue related with the use of ares_timeout() result.
Daniel S (3 October 2007) Daniel S (3 October 2007)
- Alexey Pesternikov introduced CURLOPT_OPENSOCKETFUNCTION and - Alexey Pesternikov introduced CURLOPT_OPENSOCKETFUNCTION and
CURLOPT_OPENSOCKETDATA to set a callback that allows an application to CURLOPT_OPENSOCKETDATA to set a callback that allows an application to
replace the socket() call used by libcurl. It basically allows the app to replace the socket() call used by libcurl. It basically allows the app to

Просмотреть файл

@ -19,6 +19,7 @@ This release includes the following changes:
o added CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 and --hostpubmd5 o added CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 and --hostpubmd5
o renamed CURLE_SSL_PEER_CERTIFICATE to CURLE_PEER_FAILED_VERIFICATION o renamed CURLE_SSL_PEER_CERTIFICATE to CURLE_PEER_FAILED_VERIFICATION
o added CURLOPT_OPENSOCKETFUNCTION and CURLOPT_OPENSOCKETDATA o added CURLOPT_OPENSOCKETFUNCTION and CURLOPT_OPENSOCKETDATA
o CULROPT_COOKIELIST supports "FLUSH"
This release includes the following bugfixes: This release includes the following bugfixes:
@ -53,6 +54,6 @@ advice from friends like these:
Dan Fandrich, Michal Marek, Günter Knauf, Rob Crittenden, Immanuel Gregoire, Dan Fandrich, Michal Marek, Günter Knauf, Rob Crittenden, Immanuel Gregoire,
Mark Davies, Max Katsev, Philip Langdale, Alex Fishman, Johnny Luong, Mark Davies, Max Katsev, Philip Langdale, Alex Fishman, Johnny Luong,
Alexey Pesternikov, Yang Tse, Kim Rinnewitz Alexey Pesternikov, Yang Tse, Kim Rinnewitz, Michael Wallner
Thanks! (and sorry if I forgot to mention someone) Thanks! (and sorry if I forgot to mention someone)

Просмотреть файл

@ -810,7 +810,9 @@ format or just regular HTTP-style header (Set-Cookie: ...) format. If cURL
cookie engine was not enabled it will enable its cookie engine. Passing a cookie engine was not enabled it will enable its cookie engine. Passing a
magic string \&"ALL" will erase all cookies known by cURL. (Added in 7.14.1) magic string \&"ALL" will erase all cookies known by cURL. (Added in 7.14.1)
Passing the special string \&"SESS" will only erase all session cookies known Passing the special string \&"SESS" will only erase all session cookies known
by cURL. (Added in 7.15.4) by cURL. (Added in 7.15.4) Passing the special string \&"FLUSH" will write
all cookies known by cURL to the file specified by \fICURLOPT_COOKIEJAR\fP.
(Added in 7.17.1)
.IP CURLOPT_HTTPGET .IP CURLOPT_HTTPGET
Pass a long. If the long is non-zero, this forces the HTTP request to get back Pass a long. If the long is non-zero, this forces the HTTP request to get back
to GET. usable if a POST, HEAD, PUT or a custom request have been used to GET. usable if a POST, HEAD, PUT or a custom request have been used

Просмотреть файл

@ -165,6 +165,10 @@ static void signalPipeClose(struct curl_llist *pipeline);
static struct SessionHandle* gethandleathead(struct curl_llist *pipeline); static struct SessionHandle* gethandleathead(struct curl_llist *pipeline);
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
static void flush_cookies(struct SessionHandle *data, int cleanup);
#endif
#define MAX_PIPELINE_LENGTH 5 #define MAX_PIPELINE_LENGTH 5
/* /*
@ -269,6 +273,36 @@ CURLcode Curl_dupset(struct SessionHandle * dst, struct SessionHandle * src)
return r; return r;
} }
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
static void flush_cookies(struct SessionHandle *data, int cleanup)
{
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
if(data->set.str[STRING_COOKIEJAR]) {
if(data->change.cookielist) {
/* If there is a list of cookie files to read, do it first so that
we have all the told files read before we write the new jar */
Curl_cookie_loadfiles(data);
}
/* we have a "destination" for all the cookies to get dumped to */
if(Curl_cookie_output(data->cookies, data->set.str[STRING_COOKIEJAR]))
infof(data, "WARNING: failed to save cookies in %s\n",
data->set.str[STRING_COOKIEJAR]);
}
else {
if(cleanup && data->change.cookielist)
/* since nothing is written, we can just free the list of cookie file
names */
curl_slist_free_all(data->change.cookielist); /* clean up list */
}
if(cleanup && (!data->share || (data->cookies != data->share->cookies))) {
Curl_cookie_cleanup(data->cookies);
}
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
#endif
/* /*
* This is the internal function curl_easy_cleanup() calls. This should * This is the internal function curl_easy_cleanup() calls. This should
* cleanup and free all resources associated with this sessionhandle. * cleanup and free all resources associated with this sessionhandle.
@ -380,30 +414,7 @@ CURLcode Curl_close(struct SessionHandle *data)
Curl_safefree(data->state.headerbuff); Curl_safefree(data->state.headerbuff);
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); flush_cookies(data, 1);
if(data->set.str[STRING_COOKIEJAR]) {
if(data->change.cookielist) {
/* If there is a list of cookie files to read, do it first so that
we have all the told files read before we write the new jar */
Curl_cookie_loadfiles(data);
}
/* we have a "destination" for all the cookies to get dumped to */
if(Curl_cookie_output(data->cookies, data->set.str[STRING_COOKIEJAR]))
infof(data, "WARNING: failed to save cookies in %s\n",
data->set.str[STRING_COOKIEJAR]);
}
else {
if(data->change.cookielist)
/* since nothing is written, we can just free the list of cookie file
names */
curl_slist_free_all(data->change.cookielist); /* clean up list */
}
if( !data->share || (data->cookies != data->share->cookies) ) {
Curl_cookie_cleanup(data->cookies);
}
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
#endif #endif
Curl_digest_cleanup(data); Curl_digest_cleanup(data);
@ -1089,6 +1100,11 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
Curl_cookie_clearsess(data->cookies); Curl_cookie_clearsess(data->cookies);
break; break;
} }
else if(strequal(argptr, "FLUSH")) {
/* flush cookies to file */
flush_cookies(data, 0);
break;
}
if(!data->cookies) if(!data->cookies)
/* if cookie engine was not running, activate it */ /* if cookie engine was not running, activate it */