comparison 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
comparison
equal deleted inserted replaced
667:a93d5324f400 668:b0c1a46b1f15
136 *back = 0; 136 *back = 0;
137 137
138 if (s = strstr(buf, "\r\n\r\n")) { 138 if (s = strstr(buf, "\r\n\r\n")) {
139 failure_kind fk; 139 failure_kind fk;
140 char *cmd, *path, *headers, path_copy[uw_bufsize+1], *inputs; 140 char *cmd, *path, *headers, path_copy[uw_bufsize+1], *inputs;
141 int id, pass;
142 141
143 s[2] = 0; 142 s[2] = 0;
144 143
145 if (!(s = strstr(buf, "\r\n"))) { 144 if (!(s = strstr(buf, "\r\n"))) {
146 fprintf(stderr, "No newline in buf\n"); 145 fprintf(stderr, "No newline in buf\n");
167 if (!strsep(&s, " ")) { 166 if (!strsep(&s, " ")) {
168 fprintf(stderr, "No second space in HTTP command\n"); 167 fprintf(stderr, "No second space in HTTP command\n");
169 break; 168 break;
170 } 169 }
171 170
172 if (sscanf(path, "/.msgs/%d/%d", &id, &pass) == 2) { 171 uw_set_headers(ctx, headers);
173 uw_client_connect(id, pass, sock); 172
174 dont_close = 1; 173 if (!strcmp(path, "/.msgs")) {
174 char *id = uw_Basis_requestHeader(ctx, "UrWeb-Client");
175 char *pass = uw_Basis_requestHeader(ctx, "UrWeb-Pass");
176
177 if (id && pass) {
178 size_t idn = atoi(id);
179 uw_client_connect(idn, atoi(pass), sock);
180 dont_close = 1;
181 fprintf(stderr, "Processed request for messages by client %d\n\n", (int)idn);
182 }
175 break; 183 break;
176 } 184 }
177 185
178 if (inputs = strchr(path, '?')) { 186 if (inputs = strchr(path, '?')) {
179 char *name, *value; 187 char *name, *value;
194 uw_set_input(ctx, name, ""); 202 uw_set_input(ctx, name, "");
195 } 203 }
196 } 204 }
197 205
198 printf("Serving URI %s....\n", path); 206 printf("Serving URI %s....\n", path);
199
200 uw_set_headers(ctx, headers);
201 207
202 while (1) { 208 while (1) {
203 if (uw_db_begin(ctx)) { 209 if (uw_db_begin(ctx)) {
204 printf("Error running SQL BEGIN\n"); 210 printf("Error running SQL BEGIN\n");
205 if (retries_left) 211 if (retries_left)