diff --git a/qse/lib/http/httpd-dir.c b/qse/lib/http/httpd-dir.c index 3b0983ac..57517707 100644 --- a/qse/lib/http/httpd-dir.c +++ b/qse/lib/http/httpd-dir.c @@ -399,8 +399,14 @@ static QSE_INLINE int task_main_dir ( dir = (task_dir_t*)task->ctx; x = task; + /* + * I've commented out the check for a slash at the end of the query path + * expecting that redirection is performed by the caller if such a condition + * isn't met or that redirection is not required under such a condition. + if (qse_mbsend (dir->qpath.ptr, QSE_MT("/"))) { + */ if (httpd->opt.scb.dir.open (httpd, dir->path.ptr, &handle) <= -1) { int http_errnum; @@ -429,6 +435,7 @@ static QSE_INLINE int task_main_dir ( httpd->opt.scb.dir.close (httpd, handle); return -1; } + /* } else { @@ -438,6 +445,7 @@ static QSE_INLINE int task_main_dir ( return (x == QSE_NULL)? -1: 0; } + */ } qse_httpd_task_t* qse_httpd_entaskdir ( diff --git a/qse/lib/http/httpd-std.c b/qse/lib/http/httpd-std.c index c3edf2e8..043dd479 100644 --- a/qse/lib/http/httpd-std.c +++ b/qse/lib/http/httpd-std.c @@ -2200,6 +2200,11 @@ static void free_resource ( QSE_MMGR_FREE (httpd->mmgr, (qse_mchar_t*)target->u.reloc.dst); break; + case QSE_HTTPD_RSRC_REDIR: + if (target->u.redir.dst != qpath) + QSE_MMGR_FREE (httpd->mmgr, (qse_mchar_t*)target->u.redir.dst); + break; + default: /* nothing to do */ break; @@ -2561,6 +2566,14 @@ auth_ok: /* free xpath since it won't be used */ QSE_MMGR_FREE (httpd->mmgr, tmp.xpath); } + else if (tmp.qpath[tmp.qpath_len - 1] != QSE_MT('/')) + { + /* the query path doesn't end with a slash. so redirect it */ + target->type = QSE_HTTPD_RSRC_REDIR; + target->u.redir.dst = tmp.qpath; + /* free xpath since it won't be used */ + QSE_MMGR_FREE (httpd->mmgr, tmp.xpath); + } else { target->type = QSE_HTTPD_RSRC_DIR;