comparison src/c/urweb.c @ 1051:731e6aa6655a

Port rest of demo to new cookie signature; fix parsing of multiple incoming cookies
author Adam Chlipala <adamc@hcoop.net>
date Thu, 26 Nov 2009 14:58:03 -0500
parents 93315ac00394
children 7e3226c97678
comparison
equal deleted inserted replaced
1050:93315ac00394 1051:731e6aa6655a
2665 } 2665 }
2666 } 2666 }
2667 } 2667 }
2668 2668
2669 if (p = uw_Basis_requestHeader(ctx, "Cookie")) { 2669 if (p = uw_Basis_requestHeader(ctx, "Cookie")) {
2670 char *p2;
2671
2670 while (1) { 2672 while (1) {
2671 if (!strncmp(p, c, len) && p[len] == '=') 2673 if (!strncmp(p, c, len) && p[len] == '=') {
2672 return p + 1 + len; 2674 if (p2 = strchr(p, ';')) {
2673 else if (p = strchr(p, ';')) 2675 size_t n = p2 - (p + len);
2676 char *r = uw_malloc(ctx, n);
2677 memcpy(r, p + 1 + len, n-1);
2678 r[n-1] = 0;
2679 return r;
2680 } else
2681 return p + 1 + len;
2682 } else if (p = strchr(p, ';'))
2674 p += 2; 2683 p += 2;
2675 else 2684 else
2676 return NULL; 2685 return NULL;
2677 } 2686 }
2678 } 2687 }