Strip the leading slash of the rest string.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 17 Dec 2008 02:34:00 +0000 (03:34 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 17 Dec 2008 02:34:00 +0000 (03:34 +0100)
lib/req.c
lib/req.h
src/htparser.c

index 2671159..0ede229 100644 (file)
--- a/lib/req.c
+++ b/lib/req.c
@@ -89,6 +89,17 @@ char *getheader(struct hthead *head, char *name)
     return(NULL);
 }
 
+void replrest(struct hthead *head, char *rest)
+{
+    char *tmp;
+    
+    /* Do not free the current rest string yet, so that the new one
+     * can a subpart of the old one. */
+    tmp = head->rest;
+    head->rest = sstrdup(rest);
+    free(tmp);
+}
+
 void headpreheader(struct hthead *head, const char *name, const char *val)
 {
     head->headers = srealloc(head->headers, sizeof(*head->headers) * (head->noheaders + 1));
index a3fc0be..942ff35 100644 (file)
--- a/lib/req.h
+++ b/lib/req.h
@@ -17,5 +17,6 @@ void headpreheader(struct hthead *head, const char *name, const char *val);
 void headappheader(struct hthead *head, const char *name, const char *val);
 int sendreq(int sock, struct hthead *req);
 int recvreq(int sock, struct hthead **reqp);
+void replrest(struct hthead *head, char *rest);
 
 #endif
index c78f064..c0aca2e 100644 (file)
@@ -369,6 +369,10 @@ static void serve(struct muth *muth, va_list args)
            goto out;
        inbuf.b[headoff] = old;
        bufeat(inbuf, headoff);
+       /* We strip off the leading slash from the rest string, so
+        * that multiplexers can parse coherently. */
+       if(req->rest[0] == '/')
+           replrest(req, req->rest + 1);
        
        /*
         * Add metainformation and then send the request to the root