CURLOPT_COOKIELIST: Added "RELOAD" command
This commit is contained in:
Родитель
9ee8efc63b
Коммит
b10a838a7a
|
@ -46,6 +46,10 @@ erases all session cookies held in memory
|
|||
|
||||
.IP FLUSH
|
||||
writes all known cookies to the file specified by \fICURLOPT_COOKIEJAR(3)\fP
|
||||
|
||||
.IP RELOAD
|
||||
loads all cookies from the files specified by \fICURLOPT_COOKIEFILE(3)\fP
|
||||
|
||||
.SH DEFAULT
|
||||
NULL
|
||||
.SH PROTOCOLS
|
||||
|
@ -58,6 +62,8 @@ ALL was added in 7.14.1
|
|||
SESS was added in 7.15.4
|
||||
|
||||
FLUSH was added in 7.17.1
|
||||
|
||||
RELOAD was added in 7.39.0
|
||||
.SH RETURN VALUE
|
||||
Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
|
||||
CURLE_OUT_OF_MEMORY if there was insufficient heap space.
|
||||
|
|
|
@ -1191,6 +1191,11 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||
/* flush cookies to file, takes care of the locking */
|
||||
Curl_flush_cookies(data, 0);
|
||||
}
|
||||
else if(Curl_raw_equal(argptr, "RELOAD")) {
|
||||
/* reload cookies from file */
|
||||
Curl_cookie_loadfiles(data);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if(!data->cookies)
|
||||
/* if cookie engine was not running, activate it */
|
||||
|
|
|
@ -169,18 +169,42 @@ unlock: cookie [Pigs in space]: 63
|
|||
run 3: overwrite cookie 1 and 4
|
||||
lock: dns [Pigs in space]: 64
|
||||
unlock: dns [Pigs in space]: 65
|
||||
try SHARE_CLEANUP...
|
||||
lock: share [Pigs in space]: 66
|
||||
unlock: share [Pigs in space]: 67
|
||||
SHARE_CLEANUP failed, correct
|
||||
CLEANUP
|
||||
lock: cookie [Pigs in space]: 68
|
||||
unlock: cookie [Pigs in space]: 69
|
||||
lock: cookie [Pigs in space]: 66
|
||||
unlock: cookie [Pigs in space]: 67
|
||||
lock: share [Pigs in space]: 68
|
||||
unlock: share [Pigs in space]: 69
|
||||
CURLOPT_SHARE
|
||||
lock: share [Pigs in space]: 70
|
||||
unlock: share [Pigs in space]: 71
|
||||
CURLOPT_COOKIELIST ALL
|
||||
lock: cookie [Pigs in space]: 72
|
||||
unlock: cookie [Pigs in space]: 73
|
||||
CURLOPT_COOKIEJAR
|
||||
CURLOPT_COOKIELIST RELOAD
|
||||
lock: cookie [Pigs in space]: 74
|
||||
unlock: cookie [Pigs in space]: 75
|
||||
loaded cookies:
|
||||
-----------------
|
||||
.host.foo.com TRUE / FALSE 1896263787 injected yes
|
||||
.foo.com TRUE / FALSE 1993463787 test1 overwritten1
|
||||
.host.foo.com TRUE / FALSE 1896263787 test2 two
|
||||
.foo.com TRUE / FALSE 1896263787 test3 three
|
||||
.host.foo.com TRUE / FALSE 2061978987 test4 overwritten4
|
||||
.host.foo.com TRUE / FALSE 1896263787 test5 five
|
||||
-----------------
|
||||
try SHARE_CLEANUP...
|
||||
lock: share [Pigs in space]: 76
|
||||
unlock: share [Pigs in space]: 77
|
||||
SHARE_CLEANUP failed, correct
|
||||
CLEANUP
|
||||
lock: cookie [Pigs in space]: 78
|
||||
unlock: cookie [Pigs in space]: 79
|
||||
lock: share [Pigs in space]: 80
|
||||
unlock: share [Pigs in space]: 81
|
||||
SHARE_CLEANUP
|
||||
lock: share [Pigs in space]: 72
|
||||
unlock: share [Pigs in space]: 73
|
||||
lock: share [Pigs in space]: 82
|
||||
unlock: share [Pigs in space]: 83
|
||||
GLOBAL_CLEANUP
|
||||
</stdout>
|
||||
<stderr>
|
||||
|
|
|
@ -175,11 +175,13 @@ int test(char *URL)
|
|||
{
|
||||
int res;
|
||||
CURLSHcode scode = CURLSHE_OK;
|
||||
CURLcode code = CURLE_OK;
|
||||
char *url = NULL;
|
||||
struct Tdata tdata;
|
||||
CURL *curl;
|
||||
CURLSH *share;
|
||||
struct curl_slist *headers = NULL;
|
||||
struct curl_slist *cookies = NULL;
|
||||
int i;
|
||||
struct userdata user;
|
||||
|
||||
|
@ -296,6 +298,54 @@ int test(char *URL)
|
|||
printf( "PERFORM\n" );
|
||||
curl_easy_perform( curl );
|
||||
|
||||
printf( "CLEANUP\n" );
|
||||
curl_easy_cleanup( curl );
|
||||
|
||||
/* load cookies */
|
||||
if ((curl = curl_easy_init()) == NULL) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_share_cleanup(share);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
url = suburl( URL, i );
|
||||
headers = sethost( NULL );
|
||||
test_setopt( curl, CURLOPT_HTTPHEADER, headers );
|
||||
test_setopt( curl, CURLOPT_URL, url );
|
||||
printf( "CURLOPT_SHARE\n" );
|
||||
test_setopt( curl, CURLOPT_SHARE, share );
|
||||
printf( "CURLOPT_COOKIELIST ALL\n" );
|
||||
test_setopt( curl, CURLOPT_COOKIELIST, "ALL" );
|
||||
printf( "CURLOPT_COOKIEJAR\n" );
|
||||
test_setopt( curl, CURLOPT_COOKIEFILE, JAR );
|
||||
printf( "CURLOPT_COOKIELIST RELOAD\n" );
|
||||
test_setopt( curl, CURLOPT_COOKIELIST, "RELOAD" );
|
||||
|
||||
code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
|
||||
if ( code != CURLE_OK )
|
||||
{
|
||||
fprintf(stderr, "curl_easy_getinfo() failed\n");
|
||||
curl_share_cleanup(share);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
printf("loaded cookies:\n");
|
||||
if ( !cookies )
|
||||
{
|
||||
fprintf(stderr, " reloading cookies from '%s' failed\n", JAR);
|
||||
curl_share_cleanup(share);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
printf("-----------------\n");
|
||||
while ( cookies )
|
||||
{
|
||||
printf( " %s\n", cookies->data );
|
||||
cookies = cookies->next;
|
||||
}
|
||||
printf("-----------------\n");
|
||||
curl_slist_free_all( cookies );
|
||||
|
||||
/* try to free share, expect to fail because share is in use*/
|
||||
printf( "try SHARE_CLEANUP...\n" );
|
||||
scode = curl_share_cleanup( share );
|
||||
|
|
Загрузка…
Ссылка в новой задаче