diff src/c/driver.c @ 668:b0c1a46b1f15

First message send delivered, but not interpreted
author Adam Chlipala <adamc@hcoop.net>
date Sun, 22 Mar 2009 15:05:07 -0400
parents a93d5324f400
children 729e65db2e2f
line wrap: on
line diff
--- a/src/c/driver.c	Thu Mar 19 16:34:13 2009 -0400
+++ b/src/c/driver.c	Sun Mar 22 15:05:07 2009 -0400
@@ -138,7 +138,6 @@
       if (s = strstr(buf, "\r\n\r\n")) {
         failure_kind fk;
         char *cmd, *path, *headers, path_copy[uw_bufsize+1], *inputs;
-        int id, pass;
 
         s[2] = 0;
 
@@ -169,9 +168,18 @@
           break;
         }
 
-        if (sscanf(path, "/.msgs/%d/%d", &id, &pass) == 2) {
-          uw_client_connect(id, pass, sock);
-          dont_close = 1;
+        uw_set_headers(ctx, headers);
+
+        if (!strcmp(path, "/.msgs")) {
+          char *id = uw_Basis_requestHeader(ctx, "UrWeb-Client");
+          char *pass = uw_Basis_requestHeader(ctx, "UrWeb-Pass");
+
+          if (id && pass) {
+            size_t idn = atoi(id);
+            uw_client_connect(idn, atoi(pass), sock);
+            dont_close = 1;
+            fprintf(stderr, "Processed request for messages by client %d\n\n", (int)idn);
+          }
           break;
         }
 
@@ -197,8 +205,6 @@
 
         printf("Serving URI %s....\n", path);
 
-        uw_set_headers(ctx, headers);
-
         while (1) {
           if (uw_db_begin(ctx)) {
             printf("Error running SQL BEGIN\n");