diff src/c/urweb.c @ 476:c9566d49ecfe

Handle EError returning a function; handle multiple cookies in one input header
author Adam Chlipala <adamc@hcoop.net>
date Sat, 08 Nov 2008 12:12:50 -0500
parents 70ee90105fce
children 5521bb0b4014
line wrap: on
line diff
--- a/src/c/urweb.c	Sat Nov 08 10:58:59 2008 -0500
+++ b/src/c/urweb.c	Sat Nov 08 12:12:50 2008 -0500
@@ -1193,9 +1193,21 @@
   }
 
   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;
+    if (!strncasecmp(s, "Cookie: ", 8)) {
+      p += 2;
+      while (1) {
+        if (!strncmp(p, c, len)
+            && p + len < ctx->headers_end && p[len] == '=')
+          return p + 1 + len;
+        else if (p = strchr(p, ';'))
+          p += 2;
+        else if ((s = strchr(s, 0)) && s < ctx->headers_end) {
+          s += 2;
+          break;
+        }
+        else
+          return NULL;
+      }
     } else {
       if ((s = strchr(p, 0)) && s < ctx->headers_end)
         s += 2;