src/server/daemon/httprequest.c

changeset 180
98462e878ca7
parent 168
5c752979bfd6
child 193
aa8393527b1e
--- a/src/server/daemon/httprequest.c	Mon Mar 06 17:32:26 2017 +0100
+++ b/src/server/daemon/httprequest.c	Wed Aug 30 21:53:08 2017 +0200
@@ -45,8 +45,7 @@
 #include "error.h"
 
 void http_request_init(HTTPRequest *req) {
-    req->connection = NULL;
-    req->uri.ptr = NULL;
+    memset(req, 0, sizeof(HTTPRequest));
 
     HeaderArray *hd = malloc(sizeof(HeaderArray));
     hd->next = NULL;
@@ -155,14 +154,13 @@
     // Pass request line as "clf-request"
     // remove \r\n 
     sstr_t clfreq = request->request_line;
-    while(clfreq.ptr[clfreq.length - 1] < 33) {
+    while(clfreq.length > 0 && clfreq.ptr[clfreq.length - 1] < 33) {
         clfreq.length--;
     }
-    request->request_line = clfreq;
     pblock_kvinsert(
             pb_key_clf_request,
-            request->request_line.ptr,
-            request->request_line.length,
+            clfreq.ptr,
+            clfreq.length,
             rq->rq.reqpb);
 
     // Pass method as "method" in reqpb, and also as method_num

mercurial