enhanced httpd proxy handling
This commit is contained in:
parent
77721b0c94
commit
45b7832b99
@ -86,6 +86,7 @@ struct qse_htre_t
|
||||
qse_size_t content_length;
|
||||
int keepalive;
|
||||
const qse_mchar_t* expect;
|
||||
const qse_mchar_t* status;
|
||||
} attr;
|
||||
|
||||
/* header table */
|
||||
|
@ -552,6 +552,12 @@ static int capture_expect (qse_htrd_t* htrd, qse_htb_pair_t* pair)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int capture_status (qse_htrd_t* htrd, qse_htb_pair_t* pair)
|
||||
{
|
||||
htrd->re.attr.status = QSE_HTB_VPTR(pair);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int capture_transfer_encoding (qse_htrd_t* htrd, qse_htb_pair_t* pair)
|
||||
{
|
||||
int n;
|
||||
@ -590,6 +596,7 @@ static QSE_INLINE int capture_key_header (
|
||||
{ "Connection", 10, capture_connection },
|
||||
{ "Content-Length", 14, capture_content_length },
|
||||
{ "Expect", 6, capture_expect },
|
||||
{ "Status", 6, capture_status },
|
||||
{ "Transfer-Encoding", 17, capture_transfer_encoding }
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -163,7 +163,8 @@ static qse_httpd_task_t* enqueue_task (
|
||||
qse_httpd_allocmem (httpd, QSE_SIZEOF(*new_task) + xtnsize);
|
||||
if (new_task == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_MEMCPY (new_task, task, QSE_SIZEOF(*new_task));
|
||||
QSE_MEMSET (new_task, 0, QSE_SIZEOF(*new_task) + xtnsize);
|
||||
*new_task = *task;
|
||||
|
||||
if (new_task->init)
|
||||
{
|
||||
@ -430,6 +431,7 @@ qse_printf (QSE_T("failed to accept from server %s\n"), tmp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("MUX ADDHND CLIENT READ %d\n"), client->handle.i);
|
||||
if (httpd->cbs->mux.addhnd (
|
||||
httpd, mux, client->handle, QSE_HTTPD_MUX_READ,
|
||||
perform_client_task, client) <= -1)
|
||||
@ -533,6 +535,7 @@ qse_printf (QSE_T("FAILED TO ACTIVATE SERVER....\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("MUX ADDHND SERVER %d\n"), server->handle.i);
|
||||
if (httpd->cbs->mux.addhnd (
|
||||
httpd, httpd->mux, server->handle, QSE_HTTPD_MUX_READ,
|
||||
accept_client, server) <= -1)
|
||||
@ -1001,8 +1004,14 @@ qse_httpd_task_t* qse_httpd_entask (
|
||||
{
|
||||
qse_httpd_task_t* new_task;
|
||||
|
||||
if (client->status & CLIENT_BAD) return QSE_NULL;
|
||||
|
||||
new_task = enqueue_task (httpd, client, pred, task, xtnsize);
|
||||
if (new_task == QSE_NULL) purge_client (httpd, client);
|
||||
if (new_task == QSE_NULL)
|
||||
{
|
||||
/*purge_client (httpd, client);*/
|
||||
client->status |= CLIENT_BAD;
|
||||
}
|
||||
else if (new_task->prev == QSE_NULL)
|
||||
{
|
||||
/* this new task is the first task for a client */
|
||||
@ -1014,12 +1023,14 @@ qse_httpd_task_t* qse_httpd_entask (
|
||||
httpd->cbs->mux.delhnd (httpd, httpd->mux, client->handle);
|
||||
client->status &= ~CLIENT_HANDLE_IN_MUX;
|
||||
|
||||
qse_printf (QSE_T("MUX ADDHND CLIENT RW(ENTASK) %d\n"), client->handle.i);
|
||||
if (httpd->cbs->mux.addhnd (
|
||||
httpd, httpd->mux, client->handle,
|
||||
QSE_HTTPD_MUX_READ | QSE_HTTPD_MUX_WRITE,
|
||||
perform_client_task, client) <= -1)
|
||||
{
|
||||
purge_client (httpd, client);
|
||||
/*purge_client (httpd, client);*/
|
||||
client->status |= CLIENT_BAD;
|
||||
new_task = QSE_NULL;
|
||||
}
|
||||
client->status |= CLIENT_HANDLE_IN_MUX; /* READ | WRITE */
|
||||
|
@ -605,7 +605,6 @@ static int mux_addhnd (
|
||||
|
||||
ev.data.ptr = mev;
|
||||
|
||||
qse_printf (QSE_T("MUX ADDING %d\n"), (int)handle.i);
|
||||
if (epoll_ctl (mux->fd, EPOLL_CTL_ADD, handle.i, &ev) <= -1)
|
||||
{
|
||||
/* don't rollback ee.ptr */
|
||||
@ -627,7 +626,6 @@ static int mux_delhnd (qse_httpd_t* httpd, void* vmux, qse_ubi_t handle)
|
||||
return -1;
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("MUX DELETING %d\n"), (int)handle.i);
|
||||
mux->ee.len--;
|
||||
return 0;
|
||||
}
|
||||
@ -660,7 +658,6 @@ static int mux_poll (qse_httpd_t* httpd, void* vmux, qse_ntime_t timeout)
|
||||
if (mev->reqmask & QSE_HTTPD_MUX_WRITE) mask |= QSE_HTTPD_MUX_WRITE;
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("MUX EXEC %d\n"), (int)mev->handle.i);
|
||||
mev->cbfun (httpd, mux, mev->handle, mask, mev->cbarg);
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user