comparison src/c/driver.c @ 457:360cbc202756

Request header reading works
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Nov 2008 09:47:16 -0500
parents b10132434adc
children 8f65b0fa3b29
comparison
equal deleted inserted replaced
456:1a4fa157fedd 457:360cbc202756
133 back += r; 133 back += r;
134 *back = 0; 134 *back = 0;
135 135
136 if (s = strstr(buf, "\r\n\r\n")) { 136 if (s = strstr(buf, "\r\n\r\n")) {
137 failure_kind fk; 137 failure_kind fk;
138 char *cmd, *path, path_copy[uw_bufsize+1], *inputs; 138 char *cmd, *path, *headers, path_copy[uw_bufsize+1], *inputs;
139 139
140 *s = 0; 140 *s = 0;
141 141
142 if (!(s = strstr(buf, "\r\n"))) { 142 if (!(s = strstr(buf, "\r\n"))) {
143 fprintf(stderr, "No newline in buf\n"); 143 fprintf(stderr, "No newline in buf\n");
144 break; 144 break;
145 } 145 }
146 146
147 *s = 0; 147 *s = 0;
148 headers = s + 2;
148 cmd = s = buf; 149 cmd = s = buf;
149 150
150 printf("Read: %s\n", buf); 151 printf("Read: %s\n", buf);
151 152
152 if (!strsep(&s, " ")) { 153 if (!strsep(&s, " ")) {
206 uw_write(ctx, "HTTP/1.1 200 OK\r\n"); 207 uw_write(ctx, "HTTP/1.1 200 OK\r\n");
207 uw_write(ctx, "Content-type: text/html\r\n\r\n"); 208 uw_write(ctx, "Content-type: text/html\r\n\r\n");
208 uw_write(ctx, "<html>"); 209 uw_write(ctx, "<html>");
209 210
210 strcpy(path_copy, path); 211 strcpy(path_copy, path);
211 fk = uw_begin(ctx, path_copy); 212 fk = uw_begin(ctx, headers, path_copy);
212 if (fk == SUCCESS) { 213 if (fk == SUCCESS) {
213 uw_write(ctx, "</html>"); 214 uw_write(ctx, "</html>");
214 215
215 if (uw_db_commit(ctx)) { 216 if (uw_db_commit(ctx)) {
216 fk = FATAL; 217 fk = FATAL;