]> www.dolda2000.com Git - ashd.git/commitdiff
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 26711599a3879eec1697fbba7582b78522ee4a69..0ede22906869c55d308fd9f3e5e4d9632ce35fe4 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 a3fc0be75bfe18f02b82de31355947ca67000e49..942ff3505f1d39f7c0641ec51d02b7ad001b51a3 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 c78f064c33f7775e1e7882586a510dc76876830b..c0aca2e535fb231cc0349755e59feac2f900f0c8 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