diff options
author | 2008-11-06 12:08:41 -0500 | |
---|---|---|
committer | 2008-11-06 12:08:41 -0500 | |
commit | 9f6397d0f801f6e020aa6123f14ddc44e11deee7 (patch) | |
tree | ab9e9c68fbb15a38d5a42e489dbc1ecdfd886525 /src/c/urweb.c | |
parent | bfad3d26b4471c93b92d41c894e25919fd7bf953 (diff) |
Reading cookies works
Diffstat (limited to 'src/c/urweb.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) { |