added qse_httpd_entasktextwithmvk()
This commit is contained in:
parent
893c3f74f8
commit
cc2aeb50ab
@ -1173,12 +1173,23 @@ QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskformat (
|
||||
/* -------------------------------------------- */
|
||||
|
||||
QSE_EXPORT qse_httpd_task_t* qse_httpd_entasktext (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* text,
|
||||
const qse_mchar_t* mime,
|
||||
qse_htre_t* req
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* text,
|
||||
const qse_mchar_t* mime,
|
||||
qse_htre_t* req
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_httpd_task_t* qse_httpd_entasktextwithmvk (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* text,
|
||||
const qse_mchar_t* mime,
|
||||
qse_http_method_t method,
|
||||
const qse_http_version_t* version,
|
||||
int keepalive
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskerror (
|
||||
|
@ -69,14 +69,81 @@ static int task_main_text (
|
||||
return 1; /* more work to do */
|
||||
}
|
||||
|
||||
qse_httpd_task_t* qse_httpd_entasktextwithmvk (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* text,
|
||||
const qse_mchar_t* mime,
|
||||
qse_http_method_t method,
|
||||
const qse_http_version_t* version,
|
||||
int keepalive)
|
||||
{
|
||||
qse_size_t tlen;
|
||||
qse_mchar_t b_tlen[64];
|
||||
|
||||
qse_httpd_task_t task;
|
||||
task_text_t data;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case QSE_HTTP_HEAD:
|
||||
tlen = 0;
|
||||
break;
|
||||
|
||||
case QSE_HTTP_GET:
|
||||
case QSE_HTTP_POST:
|
||||
tlen = qse_mbslen(text);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Method not allowed */
|
||||
return qse_httpd_entaskerrorwithmvk (httpd, client, pred, 405, method, version, keepalive);
|
||||
}
|
||||
|
||||
qse_fmtuintmaxtombs (b_tlen, QSE_COUNTOF(b_tlen), tlen, 10, -1, QSE_MT('\0'), QSE_NULL);
|
||||
pred = qse_httpd_entaskformat (
|
||||
httpd, client, pred,
|
||||
QSE_MT("HTTP/%d.%d 200 OK\r\nServer: %s\r\nDate: %s\r\nConnection: %s\r\nContent-Type: %s\r\nContent-Length: %s\r\n\r\n"),
|
||||
version->major, version->minor,
|
||||
qse_httpd_getname (httpd),
|
||||
qse_httpd_fmtgmtimetobb (httpd, QSE_NULL, 0),
|
||||
(keepalive? QSE_MT("keep-alive"): QSE_MT("close")),
|
||||
mime, b_tlen
|
||||
);
|
||||
if (pred == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_MEMSET (&data, 0, QSE_SIZEOF(data));
|
||||
data.ptr = text;
|
||||
data.left = tlen;
|
||||
|
||||
QSE_MEMSET (&task, 0, QSE_SIZEOF(task));
|
||||
task.init = task_init_text;
|
||||
task.main = task_main_text;
|
||||
task.ctx = &data;
|
||||
|
||||
return qse_httpd_entask (httpd, client, pred, &task, QSE_SIZEOF(data) + data.left);
|
||||
}
|
||||
|
||||
qse_httpd_task_t* qse_httpd_entasktext (
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_t* httpd,
|
||||
qse_httpd_client_t* client,
|
||||
qse_httpd_task_t* pred,
|
||||
const qse_mchar_t* text,
|
||||
const qse_mchar_t* mime,
|
||||
qse_htre_t* req)
|
||||
{
|
||||
qse_http_method_t method;
|
||||
qse_http_version_t* version;
|
||||
|
||||
|
||||
method = qse_htre_getqmethodtype (req);
|
||||
version = qse_htre_getversion (req);
|
||||
|
||||
qse_htre_discardcontent (req);
|
||||
return qse_httpd_entasktextwithmvk (httpd, client, pred, text, mime, method, version, (req->flags & QSE_HTRE_ATTR_KEEPALIVE));
|
||||
|
||||
#if 0
|
||||
qse_size_t tlen;
|
||||
qse_mchar_t b_tlen[64];
|
||||
qse_http_method_t method;
|
||||
@ -127,4 +194,5 @@ qse_httpd_task_t* qse_httpd_entasktext (
|
||||
task.ctx = &data;
|
||||
|
||||
return qse_httpd_entask (httpd, client, pred, &task, QSE_SIZEOF(data) + data.left);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user