diff options
author | 2009-11-26 14:58:03 -0500 | |
---|---|---|
committer | 2009-11-26 14:58:03 -0500 | |
commit | b9982e3f5bb8c01d2b2b787b39d3a0b6796d0e8d (patch) | |
tree | c4f546b0c0bd72967f57a3eed178a21cadd17daa /src/c/urweb.c | |
parent | 20a451e11a5c10d4751beebcf09e0c86568ac5d2 (diff) |
Port rest of demo to new cookie signature; fix parsing of multiple incoming cookies
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r-- | src/c/urweb.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index cbe065c3..aaa1278f 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -2667,10 +2667,19 @@ uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) { } if (p = uw_Basis_requestHeader(ctx, "Cookie")) { + char *p2; + while (1) { - if (!strncmp(p, c, len) && p[len] == '=') - return p + 1 + len; - else if (p = strchr(p, ';')) + if (!strncmp(p, c, len) && p[len] == '=') { + if (p2 = strchr(p, ';')) { + size_t n = p2 - (p + len); + char *r = uw_malloc(ctx, n); + memcpy(r, p + 1 + len, n-1); + r[n-1] = 0; + return r; + } else + return p + 1 + len; + } else if (p = strchr(p, ';')) p += 2; else return NULL; |