aboutsummaryrefslogtreecommitdiff
path: root/lib/cookie.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-02-01 23:54:51 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-02-01 23:54:51 +0000
commitc6a8bb3d5642ab674f884c535ca4955b951f2ff8 (patch)
tree439be1638897516f4378b1706f6ccdb9a82f7330 /lib/cookie.c
parent0bc8d2ea1f3e40c1d943849491b9479c01c150ef (diff)
Added some RFC2109 support
Diffstat (limited to 'lib/cookie.c')
-rw-r--r--lib/cookie.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index dde335042..613c52e7f 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -101,6 +101,7 @@ struct Cookie *cookie_add(struct CookieInfo *c,
*semiptr='\0'; /* zero terminate for a while */
/* we have a <what>=<this> pair or a 'secure' word here */
if(strchr(ptr, '=')) {
+ name[0]=what[0]=0; /* init the buffers */
if(2 == sscanf(ptr, "%" MAX_NAME_TXT "[^=]=%"
MAX_COOKIE_LINE_TXT "[^\r\n]",
name, what)) {
@@ -111,6 +112,23 @@ struct Cookie *cookie_add(struct CookieInfo *c,
else if(strequal("domain", name)) {
co->domain=strdup(what);
}
+ else if(strequal("version", name)) {
+ co->version=strdup(what);
+ }
+ else if(strequal("max-age", name)) {
+ /* Defined in RFC2109:
+
+ Optional. The Max-Age attribute defines the lifetime of the
+ cookie, in seconds. The delta-seconds value is a decimal non-
+ negative integer. After delta-seconds seconds elapse, the
+ client should discard the cookie. A value of zero means the
+ cookie should be discarded immediately.
+
+ */
+ co->maxage = strdup(what);
+ co->expires =
+ atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]);
+ }
else if(strequal("expires", name)) {
co->expirestr=strdup(what);
co->expires = get_date(what, &now);
@@ -264,6 +282,11 @@ struct Cookie *cookie_add(struct CookieInfo *c,
if(clist->expirestr)
free(clist->expirestr);
+ if(clist->version)
+ free(clist->version);
+ if(clist->maxage)
+ free(clist->maxage);
+
*clist = *co; /* then store all the new data */
}
@@ -448,6 +471,11 @@ void cookie_cleanup(struct CookieInfo *c)
if(co->expirestr)
free(co->expirestr);
+ if(co->version)
+ free(co->version);
+ if(co->maxage)
+ free(co->maxage);
+
next = co->next;
free(co);
co = next;