captured X-HTTP-Method-Override in http-thr.c

This commit is contained in:
hyung-hwan 2020-06-08 18:11:36 +00:00
parent a910dd533c
commit b8f96c0b74
3 changed files with 33 additions and 2 deletions

View File

@ -803,7 +803,7 @@ static int cgi_peer_capture_request_header (mio_htre_t* req, const mio_bch_t* ke
while (val) while (val)
{ {
if (mio_becs_cat(dbuf, ",") == (mio_oow_t)-1 || if (mio_becs_cat(dbuf, ",") == (mio_oow_t)-1 ||
mio_becs_cat (dbuf, val->ptr) == (mio_oow_t)-1) return -1; mio_becs_cat(dbuf, val->ptr) == (mio_oow_t)-1) return -1;
val = val->next; val = val->next;
} }

View File

@ -786,6 +786,33 @@ static void thr_func (mio_t* mio, mio_dev_thr_iopair_t* iop, void* ctx)
pthread_cleanup_pop (1); pthread_cleanup_pop (1);
} }
static int thr_capture_request_header (mio_htre_t* req, const mio_bch_t* key, const mio_htre_hdrval_t* val, void* ctx)
{
thr_func_start_t* tfs = (thr_func_start_t*)ctx;
if (mio_comp_bcstr(key, "X-HTTP-Method-Override", 1) == 0)
{
tfs->tfi.req_x_http_method_override = mio_bchars_to_http_method(val->ptr, val->len); /* don't care about multiple values */
}
#if 0
if (mio_comp_bcstr(key, "Connection", 1) != 0 &&
mio_comp_bcstr(key, "Transfer-Encoding", 1) != 0 &&
mio_comp_bcstr(key, "Content-Length", 1) != 0 &&
mio_comp_bcstr(key, "Expect", 1) != 0)
{
do
{
/* TODO: ... */
val = val->next;
}
while (val);
}
#endif
return 0;
}
int mio_svc_htts_dothr (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t* req, mio_svc_htts_thr_func_t func, void* ctx) int mio_svc_htts_dothr (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t* req, mio_svc_htts_thr_func_t func, void* ctx)
{ {
mio_t* mio = htts->mio; mio_t* mio = htts->mio;
@ -814,7 +841,10 @@ int mio_svc_htts_dothr (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t* r
tfs->tfi.req_param = mio_dupbcstr(mio, mio_htre_getqparam(req), MIO_NULL); tfs->tfi.req_param = mio_dupbcstr(mio, mio_htre_getqparam(req), MIO_NULL);
if (!tfs->tfi.req_param) goto oops; if (!tfs->tfi.req_param) goto oops;
} }
/* TODO: copy headers.. */
tfs->tfi.req_x_http_method_override = -1;
if (mio_htre_walkheaders(req, thr_capture_request_header, tfs) <= -1) return -1;
tfs->tfi.server_addr = cli->sck->localaddr; tfs->tfi.server_addr = cli->sck->localaddr;
tfs->tfi.client_addr = cli->sck->remoteaddr; tfs->tfi.client_addr = cli->sck->remoteaddr;

View File

@ -134,6 +134,7 @@ struct mio_svc_htts_thr_func_info_t
mio_http_version_t req_version; mio_http_version_t req_version;
mio_bch_t* req_path; mio_bch_t* req_path;
mio_bch_t* req_param; mio_bch_t* req_param;
int req_x_http_method_override; /* -1 or mio_http_method_t */
/* TODO: header table */ /* TODO: header table */