src/server/daemon/httprequest.c

changeset 59
ab25c0a231d0
parent 54
3a1d5a52adfc
child 60
feb2f1e115c6
--- a/src/server/daemon/httprequest.c	Tue Mar 19 17:38:32 2013 +0100
+++ b/src/server/daemon/httprequest.c	Mon May 06 13:44:27 2013 +0200
@@ -121,7 +121,7 @@
             request->request_line.length,
             rq->rq.reqpb);
 
-    /* Pass method as "method" in reqpb, and also as method_num */
+    // Pass method as "method" in reqpb, and also as method_num
     pblock_kvinsert(
             pb_key_method,
             request->method.ptr,
@@ -131,7 +131,7 @@
     //rqRq.rq.method_num = rqHdr->GetMethodNumber();
     //PR_ASSERT(rqRq.rq.method_num != -1 || iStatus);
     
-    /* Pass protocol as "protocol" in reqpb, and also in protv_num */
+    // Pass protocol as "protocol" in reqpb, and also in protv_num
     pblock_kvinsert(
             pb_key_protocol,
             request->httpv.ptr,
@@ -156,7 +156,7 @@
             }
             absPath.length = i;
 
-            /* Pass any query as 'query' in reqpb */
+            // Pass any query as 'query' in reqpb
             pblock_kvinsert(
                     pb_key_query,
                     query.ptr,
@@ -167,25 +167,29 @@
         }
     }
     
-    /* Get abs_path part of request URI, and canonicalize the path */
+    // Get abs_path part of request URI, and canonicalize the path
     absPath.ptr = util_canonicalize_uri(
             pool,
             absPath.ptr,
             absPath.length,
             (int*)&absPath.length);
 
-    /* Decode the abs_path */
-    // TODO: decode abs_path (done?)
-
-    /* Pass the abs_path as 'uri' in reqpb */
-    pblock_kvinsert(
-            pb_key_uri,
-            absPath.ptr,
-            absPath.length,
-            rq->rq.reqpb);
+    // Decode the abs_path
+    if(util_uri_unescape_strict(absPath.ptr)) {
+        // Pass the abs_path as 'uri' in reqpb
+        pblock_kvinsert(
+                pb_key_uri,
+                absPath.ptr,
+                absPath.length,
+                rq->rq.reqpb);
+    } else {
+        // TODO: log error
+        printf("unescape failed\n");
+        pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb);
+    }
 
     // pass http header to the NSAPI request structure
-    int         hlen = request->headers->len;
+    int hlen = request->headers->len;
     HeaderArray *ha  = request->headers;
     for(int i=0;i<=hlen;i++) {
         if(i == hlen) {
@@ -224,7 +228,7 @@
 
         netbuf *nb = request->netbuf;
 
-        /* create new netbuf */
+        // create new netbuf
         NetIOStream *net_io = (NetIOStream*)net_stream_from_fd(
                 pool,
                 request->connection->fd);

mercurial