diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-11-06 12:08:41 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-11-06 12:08:41 -0500 |
commit | bffeb0e5a10ae58b8f7c3f5249b3665373236e21 (patch) | |
tree | ab9e9c68fbb15a38d5a42e489dbc1ecdfd886525 /src/c | |
parent | 09d844ebdc60010b6b19d1833c213bcbba035515 (diff) |
Reading cookies works
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/urweb.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index dc58576a..be12c5ea 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -1143,7 +1143,23 @@ uw_Basis_string uw_Basis_requestHeader(uw_context ctx, uw_Basis_string h) { return NULL; } } +} + +uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) { + int len = strlen(c); + char *s = ctx->headers, *p; + while (p = strchr(s, ':')) { + if (!strncasecmp(s, "Cookie: ", 8) && !strncmp(p + 2, c, len) + && p + 2 + len < ctx->headers_end && p[2 + len] == '=') { + return p + 3 + len; + } else { + if ((s = strchr(p, 0)) && s < ctx->headers_end) + s += 2; + else + return NULL; + } + } } uw_unit uw_Basis_set_cookie(uw_context ctx, uw_Basis_string c, uw_Basis_string v) { |