mirror of
https://github.com/curl/curl.git
synced 2026-08-25 06:03:32 +03:00
Peteris Krumins added CURLOPT_COOKIELIST and CURLINFO_COOKIELIST, which is a
simple interface to extracting and setting cookies in libcurl's internal "cookie jar". See the new cookie_interface.c example code.
This commit is contained in:
parent
463c0f7096
commit
2236ba0d20
12 changed files with 252 additions and 23 deletions
31
lib/url.c
31
lib/url.c
|
|
@ -773,6 +773,37 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||
*/
|
||||
data->set.cookiesession = (bool)va_arg(param, long);
|
||||
break;
|
||||
|
||||
case CURLOPT_COOKIELIST:
|
||||
argptr = va_arg(param, char *);
|
||||
|
||||
if (argptr == NULL)
|
||||
break;
|
||||
|
||||
if (strequal(argptr, "ALL")) {
|
||||
if (data->cookies == NULL) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
/* clear all cookies */
|
||||
Curl_cookie_freelist(data->cookies->cookies);
|
||||
data->cookies->cookies = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data->cookies)
|
||||
/* if cookie engine was not running, activate it */
|
||||
data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
|
||||
|
||||
if (checkprefix("Set-Cookie:", argptr))
|
||||
/* HTTP Header format line */
|
||||
Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);
|
||||
|
||||
else
|
||||
/* Netscape format line */
|
||||
Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
|
||||
break;
|
||||
#endif /* CURL_DISABLE_COOKIES */
|
||||
|
||||
case CURLOPT_HTTPGET:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue