added qse_httpd_entaskerror() and enhanced qse_httpd_entaskpath()

This commit is contained in:
2012-01-31 14:32:20 +00:00
parent fcd14fff1c
commit 7a7127b89f
3 changed files with 149 additions and 117 deletions

View File

@ -60,9 +60,6 @@ qse_printf (QSE_T("content = [%.*S]\n"),
if (method == QSE_HTTP_GET || method == QSE_HTTP_POST)
{
const qse_mchar_t* rangestr;
qse_http_range_t range;
const qse_mchar_t* qpath = qse_htre_getqpathptr(req);
const qse_mchar_t* dot = qse_mbsrchr (qpath, QSE_MT('.'));
@ -74,53 +71,25 @@ qse_printf (QSE_T("content = [%.*S]\n"),
if (x == QSE_NULL) goto oops;
#if 0
x = qse_httpd_entasknphcgi (httpd, client, QSE_NULL, QSE_T("/tmp/test.cgi"), qse_htre_getversion(req));
x = qse_httpd_entasknphcgi (
httpd, client, QSE_NULL, qpath, req);
if (x == QSE_NULL) goto oops;
#endif
}
else
{
rangestr = qse_htre_getheaderval (req, QSE_MT("Range"));
if (rangestr && qse_parsehttprange (rangestr, &range) <= -1)
{
#if 0
qse_httpd_entaskstatictext (httpd, client, QSE_NULL, QSE_MT("HTTP/1.1 416 Requested range not satisfiable\r\nContent-Length: 5\r\n\r\nA\r\n\r\n"));
#endif
const qse_mchar_t* msg;
msg = QSE_MT("<html><head><title>Requested range not satisfiable</title></head><body><b>REQUESTED RANGE NOT SATISFIABLE</b></body></html>");
x = qse_httpd_entaskformat (
httpd, client, QSE_NULL,
QSE_MT("HTTP/%d.%d 416 Requested range not satisfiable\r\nContent-Length: %d\r\n\r\n%s\r\n\r\n"),
req->version.major, req->version.minor,
(int)qse_mbslen(msg) + 4, msg
);
if (x == QSE_NULL) goto oops;
}
else
{
x = qse_httpd_entaskpath (
httpd, client, QSE_NULL,
qse_htre_getqpathptr(req),
(rangestr? &range: QSE_NULL),
qse_htre_getversion(req),
req->attr.keepalive
);
if (x == QSE_NULL) goto oops;
}
/* file or directory */
x = qse_httpd_entaskpath (
httpd, client, QSE_NULL, qpath, req);
if (x == QSE_NULL) goto oops;
}
}
else
{
const qse_mchar_t* msg = QSE_MT("<html><head><title>Method not allowed</title></head><body><b>REQUEST METHOD NOT ALLOWED</b></body></html>");
x = qse_httpd_entaskformat (
httpd, client, QSE_NULL,
QSE_MT("HTTP/%d.%d 405 Method not allowed\r\nContent-Length: %d\r\n\r\n%s\r\n\r\n"),
req->version.major, req->version.minor,
(int)qse_mbslen(msg) + 4, msg
);
x = qse_httpd_entaskerror (httpd, client, QSE_NULL, 405, req);
if (x == QSE_NULL) goto oops;
}
done:
if (!req->attr.keepalive)
{
x = qse_httpd_entaskdisconnect (httpd, client, QSE_NULL);