comparison src/c/urweb.c @ 1408:56ba9c442a2d

Use sigFile again; do redirects in a way that is compatible with FastCGI
author Adam Chlipala <adam@chlipala.net>
date Thu, 20 Jan 2011 16:26:54 -0500
parents 7d963b8019e6
children 6ab04cb0e4db
comparison
equal deleted inserted replaced
1407:7d963b8019e6 1408:56ba9c442a2d
239 pthread_mutex_unlock(&clients_mutex); 239 pthread_mutex_unlock(&clients_mutex);
240 return c; 240 return c;
241 } 241 }
242 242
243 static char *on_success = "HTTP/1.1 200 OK\r\n"; 243 static char *on_success = "HTTP/1.1 200 OK\r\n";
244 static char *on_redirect = "HTTP/1.1 303 See Other\r\n";
245 244
246 void uw_set_on_success(char *s) { 245 void uw_set_on_success(char *s) {
247 on_success = s; 246 on_success = s;
248 } 247 }
249 248
3402 ctx_uw_buffer_check(ctx, "page", &ctx->page, uw_buffer_used(&ctx->outHeaders)+1); 3401 ctx_uw_buffer_check(ctx, "page", &ctx->page, uw_buffer_used(&ctx->outHeaders)+1);
3403 memcpy(ctx->page.start, ctx->outHeaders.start, uw_buffer_used(&ctx->outHeaders)); 3402 memcpy(ctx->page.start, ctx->outHeaders.start, uw_buffer_used(&ctx->outHeaders));
3404 ctx->page.start[uw_buffer_used(&ctx->outHeaders)] = 0; 3403 ctx->page.start[uw_buffer_used(&ctx->outHeaders)] = 0;
3405 uw_buffer_reset(&ctx->outHeaders); 3404 uw_buffer_reset(&ctx->outHeaders);
3406 3405
3407 uw_write_header(ctx, on_redirect); 3406 uw_write_header(ctx, on_success);
3408 3407
3409 s = strchr(ctx->page.start, '\n'); 3408 s = strchr(ctx->page.start, '\n');
3410 if (s) { 3409 if (s) {
3411 char *s2; 3410 char *s2;
3412 for (++s; (s2 = strchr(s, '\n')); s = s2+1) { 3411 for (++s; (s2 = strchr(s, '\n')); s = s2+1) {
3740 if (ctx->app->on_error) { 3739 if (ctx->app->on_error) {
3741 if (r == 0) { 3740 if (r == 0) {
3742 if (ctx->app->db_begin(ctx)) 3741 if (ctx->app->db_begin(ctx))
3743 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN"); 3742 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN");
3744 3743
3745 uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\r\n"); 3744 uw_write_header(ctx, "Status: 500 Internal Server Error\r\n");
3746 uw_write_header(ctx, "Content-type: text/html\r\n\r\n"); 3745 uw_write_header(ctx, "Content-type: text/html\r\n\r\n");
3747 uw_write(ctx, begin_xhtml); 3746 uw_write(ctx, begin_xhtml);
3748 ctx->app->on_error(ctx, msg); 3747 ctx->app->on_error(ctx, msg);
3749 uw_write(ctx, "</html>"); 3748 uw_write(ctx, "</html>");
3750 } 3749 }