From: Fredrik Tolf Date: Fri, 19 Dec 2008 15:11:32 +0000 (+0100) Subject: Changed dirplex to pass the filename as an optional header and preserve the semantics... X-Git-Tag: 0.1~120 X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=commitdiff_plain;h=2fdc6fcd9036db7c9edfe80b832f0c4974400f3a Changed dirplex to pass the filename as an optional header and preserve the semantics of the rest string. --- diff --git a/src/dirplex.c b/src/dirplex.c index a79a78c..e223d7d 100644 --- a/src/dirplex.c +++ b/src/dirplex.c @@ -347,13 +347,14 @@ static struct config *getconfig(char *path) return(cf); } -static char *findfile(struct hthead *req, char *nm) +static char *findfile(struct hthead *req) { - char *p, *p2, *path, *ftmp, *buf, *rv, *p3; + char *p, *p2, *path, *ftmp, *buf, *rv, *p3, *nm; struct stat sb; DIR *dir; struct dirent *dent; + nm = req->rest; path = sstrdup("."); p = nm; rv = NULL; @@ -426,6 +427,10 @@ static char *findfile(struct hthead *req, char *nm) break; p = p2; } + if(p2 == NULL) + replrest(req, ""); + else + replrest(req, p2); if(!strncmp(rv, "./", 2)) memmove(rv, rv + 2, strlen(rv + 2) + 1); goto out; @@ -539,11 +544,10 @@ static void serve(struct hthead *req, int fd) struct pattern *pat; struct child *ch; - if((file = findfile(req, req->rest)) == NULL) { + if((file = findfile(req)) == NULL) { /* XXX: Do 404 handling */ return; } - replrest(req, file); if(stat(file, &sb)) { flog(LOG_ERR, "could not stat previously found file %s: %s", file, strerror(errno)); free(file); @@ -554,6 +558,7 @@ static void serve(struct hthead *req, int fd) free(file); return; } + headappheader(req, "X-Ash-File", file); if(((pat = findmatch(file, 0)) == NULL) && ((pat = findmatch(file, 1)) == NULL)) { /* XXX: Send a 500 error? 404? */ free(file);