moved the directory end check and redirection from httpd-dir.c to httpd-std.c

This commit is contained in:
hyung-hwan 2013-03-14 02:41:24 +00:00
parent e02ee7b452
commit 4d8c02588f
2 changed files with 21 additions and 0 deletions

View File

@ -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 (

View File

@ -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;