diff 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
line wrap: on
line diff
--- a/src/c/urweb.c	Thu Dec 16 18:40:49 2010 -0500
+++ b/src/c/urweb.c	Sat Dec 18 10:56:31 2010 -0500
@@ -445,6 +445,9 @@
   void *logger_data;
   uw_logger log_debug;
 
+  int hasPostBody;
+  uw_Basis_postBody postBody;
+
   char error_message[ERROR_BUF_LEN];
 };
 
@@ -507,6 +510,8 @@
   ctx->logger_data = logger_data;
   ctx->log_debug = log_debug;
 
+  ctx->hasPostBody = 0;
+
   return ctx;
 }
 
@@ -583,6 +588,7 @@
   ctx->cur_container = NULL;
   ctx->used_transactionals = 0;
   ctx->script_header = "";
+  ctx->hasPostBody = 0;
 }
 
 void uw_reset_keep_request(uw_context ctx) {
@@ -3200,6 +3206,14 @@
   return f.data;
 }
 
+uw_Basis_string uw_Basis_postType(uw_context ctx, uw_Basis_postBody pb) {
+  return pb.type;
+}
+
+uw_Basis_string uw_Basis_postData(uw_context ctx, uw_Basis_postBody pb) {
+  return pb.data;
+}
+
 __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, uw_Basis_string mimeType) {
   cleanup *cl;
   int len;
@@ -3458,3 +3472,23 @@
   uw_Basis_int n = abs(rand());
   return n;
 }
+
+void uw_noPostBody(uw_context ctx) {
+  ctx->hasPostBody = 0;
+}
+
+void uw_postBody(uw_context ctx, uw_Basis_postBody pb) {
+  ctx->hasPostBody = 1;
+  ctx->postBody = pb;
+}
+
+int uw_hasPostBody(uw_context ctx) {
+  return ctx->hasPostBody;
+}
+
+uw_Basis_postBody uw_getPostBody(uw_context ctx) {
+  if (ctx->hasPostBody)
+    return ctx->postBody;
+  else
+    uw_error(ctx, FATAL, "Asked for POST body when none exists");
+}