summaryrefslogtreecommitdiff
path: root/lib/cookie.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-09-26 07:08:29 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-09-26 07:08:29 +0000
commit598e8dfbfbf3ed8db75cfd574b05904ecb486c34 (patch)
tree8bad809c26fb848613988dd10191bc9626546428 /lib/cookie.c
parent9efdb68035b84dda158ca786d78c56a11d46c9fa (diff)
downloadcurl-598e8dfbfbf3ed8db75cfd574b05904ecb486c34.tar.gz
Now we're setting a default domain for received cookies so that we can
properly match those cookies in subsequent requests
Diffstat (limited to 'lib/cookie.c')
-rw-r--r--lib/cookie.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index f859b0bee..2ae3b1624 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -104,7 +104,8 @@ Example set of cookies:
struct Cookie *
Curl_cookie_add(struct CookieInfo *c,
bool httpheader, /* TRUE if HTTP header-style line */
- char *lineptr) /* first non-space of the line */
+ char *lineptr, /* first non-space of the line */
+ char *domain) /* default domain */
{
struct Cookie *clist;
char what[MAX_COOKIE_LINE];
@@ -194,6 +195,10 @@ Curl_cookie_add(struct CookieInfo *c,
ptr++;
semiptr=strchr(ptr, ';'); /* now, find the next semicolon */
} while(semiptr);
+
+ if(NULL == co->domain)
+ /* no domain given in the header line, set the default now */
+ co->domain=strdup(domain);
}
else {
/* This line is NOT a HTTP header style line, we do offer support for
@@ -441,7 +446,7 @@ struct CookieInfo *Curl_cookie_init(char *file, struct CookieInfo *inc)
while(*lineptr && isspace((int)*lineptr))
lineptr++;
- Curl_cookie_add(c, headerline, lineptr);
+ Curl_cookie_add(c, headerline, lineptr, NULL);
}
if(fromfile)
fclose(fp);
@@ -632,13 +637,13 @@ int Curl_cookie_output(struct CookieInfo *c, char *dumphere)
"%u\t" /* expires */
"%s\t" /* name */
"%s\n", /* value */
- co->domain,
+ co->domain?co->domain:"unknown",
co->field1==2?"TRUE":"FALSE",
- co->path,
+ co->path?co->path:"/",
co->secure?"TRUE":"FALSE",
(unsigned int)co->expires,
co->name,
- co->value);
+ co->value?co->value:"");
co=co->next;
}