aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-07-27 22:17:14 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-07-27 22:17:14 +0000
commit2236ba0d206fe9fef5d93889ee652feaa03fe089 (patch)
tree2651d5300c11cf99f0abd3d73b9d7ddb14efa748 /lib/url.c
parent463c0f7096f7a0e56929a8e1b4fb3c38e164ce13 (diff)
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.
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/url.c b/lib/url.c
index 98662ceb9..07a34a94e 100644
--- a/lib/url.c
+++ b/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: