diff src/c/request.c @ 1371:4e5ca2a77a4d

Fix time comparison operators; safer saving of queryStrings
author Adam Chlipala <adam@chlipala.net>
date Mon, 27 Dec 2010 12:08:00 -0500
parents 44a12a321150
children 76514ddf3a97
line wrap: on
line diff
--- a/src/c/request.c	Sun Dec 26 17:29:03 2010 -0500
+++ b/src/c/request.c	Mon Dec 27 12:08:00 2010 -0500
@@ -170,9 +170,10 @@
 
 uw_request_context uw_new_request_context(void) {
   uw_request_context r = malloc(sizeof(struct uw_rc));
-  r->path_copy_size = r->queryString_size = 0;
+  r->path_copy_size = 0;
+  r->queryString_size = 1;
   r->path_copy = malloc(0);
-  r->queryString = malloc(0);
+  r->queryString = malloc(1);
   return r;
 }
 
@@ -201,6 +202,8 @@
   int had_error = 0;
   char errmsg[ERROR_BUF_LEN];
 
+  rc->queryString[0] = 0;
+
   for (s = path; *s; ++s) {
     if (s[0] == '%' && s[1] == '2' && s[2] == '7') {
       s[0] = '\'';
@@ -389,7 +392,6 @@
         rc->queryString = realloc(rc->queryString, len+1);
       }
       strcpy(rc->queryString, inputs);
-      uw_setQueryString(ctx, rc->queryString);
 
       while (*inputs) {
         name = inputs;
@@ -416,6 +418,8 @@
   log_debug(logger_data, "Serving URI %s....\n", path);
 
   while (1) {
+    uw_setQueryString(ctx, rc->queryString);
+
     if (!had_error) {
       size_t path_len = strlen(path);