Mercurial > urweb
comparison src/c/urweb.c @ 463:bb27c7efcd90
Reading cookies works
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 06 Nov 2008 12:08:41 -0500 |
parents | 21bb5bbba2e9 |
children | 91914c15a85b |
comparison
equal
deleted
inserted
replaced
462:21bb5bbba2e9 | 463:bb27c7efcd90 |
---|---|
1141 s += 2; | 1141 s += 2; |
1142 else | 1142 else |
1143 return NULL; | 1143 return NULL; |
1144 } | 1144 } |
1145 } | 1145 } |
1146 | 1146 } |
1147 | |
1148 uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) { | |
1149 int len = strlen(c); | |
1150 char *s = ctx->headers, *p; | |
1151 | |
1152 while (p = strchr(s, ':')) { | |
1153 if (!strncasecmp(s, "Cookie: ", 8) && !strncmp(p + 2, c, len) | |
1154 && p + 2 + len < ctx->headers_end && p[2 + len] == '=') { | |
1155 return p + 3 + len; | |
1156 } else { | |
1157 if ((s = strchr(p, 0)) && s < ctx->headers_end) | |
1158 s += 2; | |
1159 else | |
1160 return NULL; | |
1161 } | |
1162 } | |
1147 } | 1163 } |
1148 | 1164 |
1149 uw_unit uw_Basis_set_cookie(uw_context ctx, uw_Basis_string c, uw_Basis_string v) { | 1165 uw_unit uw_Basis_set_cookie(uw_context ctx, uw_Basis_string c, uw_Basis_string v) { |
1150 uw_write_header(ctx, "Set-Cookie: "); | 1166 uw_write_header(ctx, "Set-Cookie: "); |
1151 uw_write_header(ctx, c); | 1167 uw_write_header(ctx, c); |