diff src/c/request.c @ 1370:44a12a321150

queryString and effectfulUrl
author Adam Chlipala <adam@chlipala.net>
date Sun, 26 Dec 2010 17:29:03 -0500
parents 87156c44824f
children 4e5ca2a77a4d
line wrap: on
line diff
--- a/src/c/request.c	Sun Dec 26 15:52:56 2010 -0500
+++ b/src/c/request.c	Sun Dec 26 17:29:03 2010 -0500
@@ -164,19 +164,21 @@
 
 
 typedef struct uw_rc {
-  size_t path_copy_size;
-  char *path_copy;
+  size_t path_copy_size, queryString_size;
+  char *path_copy, *queryString;
 } *uw_request_context;
 
 uw_request_context uw_new_request_context(void) {
   uw_request_context r = malloc(sizeof(struct uw_rc));
-  r->path_copy_size = 0;
+  r->path_copy_size = r->queryString_size = 0;
   r->path_copy = malloc(0);
+  r->queryString = malloc(0);
   return r;
 }
 
 void uw_free_request_context(uw_request_context r) {
   free(r->path_copy);
+  free(r->queryString);
   free(r);
 }
 
@@ -380,6 +382,14 @@
 
     if (inputs) {
       char *name, *value;
+      int len = strlen(inputs);
+
+      if (len+1 > rc->queryString_size) {
+        rc->queryString_size = len+1;
+        rc->queryString = realloc(rc->queryString, len+1);
+      }
+      strcpy(rc->queryString, inputs);
+      uw_setQueryString(ctx, rc->queryString);
 
       while (*inputs) {
         name = inputs;