Mercurial > urweb
comparison src/c/urweb.c @ 1347:b106ca8200b1
postBody type
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 18 Dec 2010 10:56:31 -0500 |
parents | a1aa62b472cf |
children | 87156c44824f |
comparison
equal
deleted
inserted
replaced
1346:faad7d01b200 | 1347:b106ca8200b1 |
---|---|
443 void *client_data; | 443 void *client_data; |
444 | 444 |
445 void *logger_data; | 445 void *logger_data; |
446 uw_logger log_debug; | 446 uw_logger log_debug; |
447 | 447 |
448 int hasPostBody; | |
449 uw_Basis_postBody postBody; | |
450 | |
448 char error_message[ERROR_BUF_LEN]; | 451 char error_message[ERROR_BUF_LEN]; |
449 }; | 452 }; |
450 | 453 |
451 size_t uw_headers_max = SIZE_MAX; | 454 size_t uw_headers_max = SIZE_MAX; |
452 size_t uw_page_max = SIZE_MAX; | 455 size_t uw_page_max = SIZE_MAX; |
504 | 507 |
505 ctx->client_data = uw_init_client_data(); | 508 ctx->client_data = uw_init_client_data(); |
506 | 509 |
507 ctx->logger_data = logger_data; | 510 ctx->logger_data = logger_data; |
508 ctx->log_debug = log_debug; | 511 ctx->log_debug = log_debug; |
512 | |
513 ctx->hasPostBody = 0; | |
509 | 514 |
510 return ctx; | 515 return ctx; |
511 } | 516 } |
512 | 517 |
513 size_t uw_inputs_max = SIZE_MAX; | 518 size_t uw_inputs_max = SIZE_MAX; |
581 ctx->used_deltas = 0; | 586 ctx->used_deltas = 0; |
582 ctx->client = NULL; | 587 ctx->client = NULL; |
583 ctx->cur_container = NULL; | 588 ctx->cur_container = NULL; |
584 ctx->used_transactionals = 0; | 589 ctx->used_transactionals = 0; |
585 ctx->script_header = ""; | 590 ctx->script_header = ""; |
591 ctx->hasPostBody = 0; | |
586 } | 592 } |
587 | 593 |
588 void uw_reset_keep_request(uw_context ctx) { | 594 void uw_reset_keep_request(uw_context ctx) { |
589 uw_reset_keep_error_message(ctx); | 595 uw_reset_keep_error_message(ctx); |
590 ctx->error_message[0] = 0; | 596 ctx->error_message[0] = 0; |
3198 | 3204 |
3199 uw_Basis_blob uw_Basis_fileData(uw_context ctx, uw_Basis_file f) { | 3205 uw_Basis_blob uw_Basis_fileData(uw_context ctx, uw_Basis_file f) { |
3200 return f.data; | 3206 return f.data; |
3201 } | 3207 } |
3202 | 3208 |
3209 uw_Basis_string uw_Basis_postType(uw_context ctx, uw_Basis_postBody pb) { | |
3210 return pb.type; | |
3211 } | |
3212 | |
3213 uw_Basis_string uw_Basis_postData(uw_context ctx, uw_Basis_postBody pb) { | |
3214 return pb.data; | |
3215 } | |
3216 | |
3203 __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, uw_Basis_string mimeType) { | 3217 __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, uw_Basis_string mimeType) { |
3204 cleanup *cl; | 3218 cleanup *cl; |
3205 int len; | 3219 int len; |
3206 | 3220 |
3207 ctx->returning_indirectly = 1; | 3221 ctx->returning_indirectly = 1; |
3456 | 3470 |
3457 uw_Basis_int uw_Basis_rand(uw_context ctx) { | 3471 uw_Basis_int uw_Basis_rand(uw_context ctx) { |
3458 uw_Basis_int n = abs(rand()); | 3472 uw_Basis_int n = abs(rand()); |
3459 return n; | 3473 return n; |
3460 } | 3474 } |
3475 | |
3476 void uw_noPostBody(uw_context ctx) { | |
3477 ctx->hasPostBody = 0; | |
3478 } | |
3479 | |
3480 void uw_postBody(uw_context ctx, uw_Basis_postBody pb) { | |
3481 ctx->hasPostBody = 1; | |
3482 ctx->postBody = pb; | |
3483 } | |
3484 | |
3485 int uw_hasPostBody(uw_context ctx) { | |
3486 return ctx->hasPostBody; | |
3487 } | |
3488 | |
3489 uw_Basis_postBody uw_getPostBody(uw_context ctx) { | |
3490 if (ctx->hasPostBody) | |
3491 return ctx->postBody; | |
3492 else | |
3493 uw_error(ctx, FATAL, "Asked for POST body when none exists"); | |
3494 } |