diff options
author | 2008-11-06 12:22:50 -0500 | |
---|---|---|
committer | 2008-11-06 12:22:50 -0500 | |
commit | 6e41a0ca24381fa5545fe82004275e661dd8dd6e (patch) | |
tree | f912371c11c979cbede6963adb21a3fe2318623b /src/c/driver.c | |
parent | bffeb0e5a10ae58b8f7c3f5249b3665373236e21 (diff) |
Cookie demo code; fix error message display
Diffstat (limited to 'src/c/driver.c')
-rw-r--r-- | src/c/driver.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/c/driver.c b/src/c/driver.c index 438adb8d..d884c025 100644 --- a/src/c/driver.c +++ b/src/c/driver.c @@ -189,6 +189,7 @@ static void *worker(void *data) { printf("Serving URI %s....\n", path); uw_set_headers(ctx, headers); + uw_write(ctx, "<html>"); while (1) { if (uw_db_begin(ctx)) { @@ -198,8 +199,8 @@ static void *worker(void *data) { else { fk = FATAL; uw_reset(ctx); - uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); - uw_write(ctx, "Content-type: text/plain\r\n\r\n"); + uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); + uw_write_header(ctx, "Content-type: text/plain\r\n\r\n"); uw_write(ctx, "Error running SQL BEGIN\n"); break; @@ -212,13 +213,15 @@ static void *worker(void *data) { strcpy(path_copy, path); fk = uw_begin(ctx, path_copy); if (fk == SUCCESS) { + uw_write(ctx, "</html>"); + if (uw_db_commit(ctx)) { fk = FATAL; printf("Error running SQL COMMIT\n"); uw_reset(ctx); - uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); - uw_write(ctx, "Content-type: text/plain\r\n\r\n"); + uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); + uw_write_header(ctx, "Content-type: text/plain\r\n"); uw_write(ctx, "Error running SQL COMMIT\n"); } @@ -232,8 +235,8 @@ static void *worker(void *data) { printf("Fatal error (out of retries): %s\n", uw_error_message(ctx)); uw_reset_keep_error_message(ctx); - uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); - uw_write(ctx, "Content-type: text/plain\r\n\r\n"); + uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); + uw_write_header(ctx, "Content-type: text/plain\r\n"); uw_write(ctx, "Fatal error (out of retries): "); uw_write(ctx, uw_error_message(ctx)); uw_write(ctx, "\n"); @@ -248,8 +251,8 @@ static void *worker(void *data) { printf("Fatal error: %s\n", uw_error_message(ctx)); uw_reset_keep_error_message(ctx); - uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); - uw_write(ctx, "Content-type: text/plain\r\n\r\n"); + uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\r\n"); + uw_write_header(ctx, "Content-type: text/plain\r\n"); uw_write(ctx, "Fatal error: "); uw_write(ctx, uw_error_message(ctx)); uw_write(ctx, "\n"); @@ -261,8 +264,8 @@ static void *worker(void *data) { printf("Unknown uw_handle return code!\n"); uw_reset_keep_request(ctx); - uw_write(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); - uw_write(ctx, "Content-type: text/plain\r\n\r\n"); + uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\n\r"); + uw_write_header(ctx, "Content-type: text/plain\r\n"); uw_write(ctx, "Unknown uw_handle return code!\n"); try_rollback(ctx); |