moved the req_method and req_version to the task header part as task_req_method and task_req_version respectively
This commit is contained in:
parent
d055e7b0d5
commit
ba037f1c71
@ -93,7 +93,9 @@ typedef void (*hio_svc_htts_task_on_kill_t) (
|
||||
hio_oow_t task_refcnt; \
|
||||
hio_svc_htts_task_t* task_prev; \
|
||||
hio_svc_htts_task_t* task_next; \
|
||||
hio_svc_htts_task_on_kill_t task_on_kill
|
||||
hio_svc_htts_task_on_kill_t task_on_kill; \
|
||||
hio_http_version_t task_req_version; \
|
||||
hio_http_method_t task_req_method
|
||||
|
||||
struct hio_svc_htts_task_t
|
||||
{
|
||||
@ -459,7 +461,8 @@ HIO_EXPORT int hio_svc_htts_dotxt (
|
||||
HIO_EXPORT hio_svc_htts_task_t* hio_svc_htts_task_make (
|
||||
hio_svc_htts_t* htts,
|
||||
hio_oow_t task_size,
|
||||
hio_svc_htts_task_on_kill_t on_kill
|
||||
hio_svc_htts_task_on_kill_t on_kill,
|
||||
hio_htre_t* req
|
||||
);
|
||||
|
||||
HIO_EXPORT void hio_svc_htts_task_kill (
|
||||
|
@ -66,8 +66,6 @@ struct cgi_t
|
||||
|
||||
hio_dev_sck_t* csck;
|
||||
hio_svc_htts_cli_t* client;
|
||||
hio_http_version_t req_version; /* client request */
|
||||
hio_http_method_t req_method;
|
||||
|
||||
unsigned int over: 4; /* must be large enough to accomodate CGI_OVER_ALL */
|
||||
unsigned int keep_alive: 1;
|
||||
@ -158,12 +156,12 @@ static int cgi_send_final_status_to_client (cgi_t* cgi, int status_code, int for
|
||||
|
||||
if (!force_close) force_close = !cgi->keep_alive;
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\nConnection: %hs\r\n",
|
||||
cgi->req_version.major, cgi->req_version.minor,
|
||||
cgi->task_req_version.major, cgi->task_req_version.minor,
|
||||
status_code, status_msg,
|
||||
cli->htts->server_name, dtbuf,
|
||||
(force_close? "close": "keep-alive")) == (hio_oow_t)-1) return -1;
|
||||
|
||||
if (cgi->req_method == HIO_HTTP_HEAD)
|
||||
if (cgi->task_req_method == HIO_HTTP_HEAD)
|
||||
{
|
||||
if (status_code != HIO_HTTP_STATUS_OK) content_len = 0;
|
||||
status_msg = "";
|
||||
@ -573,7 +571,7 @@ static int peer_htrd_peek (hio_htrd_t* htrd, hio_htre_t* req)
|
||||
|
||||
hio_svc_htts_fmtgmtime (cli->htts, HIO_NULL, dtbuf, HIO_COUNTOF(dtbuf));
|
||||
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d ", cgi->req_version.major, cgi->req_version.minor) == (hio_oow_t)-1) return -1;
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d ", cgi->task_req_version.major, cgi->task_req_version.minor) == (hio_oow_t)-1) return -1;
|
||||
if (status_line)
|
||||
{
|
||||
if (hio_becs_fcat(cli->sbuf, "%hs\r\n", status_line) == (hio_oow_t)-1) return -1;
|
||||
@ -1020,14 +1018,12 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
||||
mi.on_fork = cgi_peer_on_fork;
|
||||
mi.fork_ctx = &fc;
|
||||
|
||||
cgi = (cgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*cgi), cgi_on_kill);
|
||||
cgi = (cgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*cgi), cgi_on_kill, req);
|
||||
if (HIO_UNLIKELY(!cgi)) goto oops;
|
||||
|
||||
cgi->options = options;
|
||||
/*cgi->num_pending_writes_to_client = 0;
|
||||
cgi->num_pending_writes_to_peer = 0;*/
|
||||
cgi->req_method = hio_htre_getqmethodtype(req);
|
||||
cgi->req_version = *hio_htre_getversion(req);
|
||||
cgi->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &cgi->req_content_length);
|
||||
|
||||
cgi->csck = csck;
|
||||
@ -1100,7 +1096,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
||||
hio_bch_t msgbuf[64];
|
||||
hio_oow_t msglen;
|
||||
|
||||
msglen = hio_fmttobcstr(hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", cgi->req_version.major, cgi->req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
msglen = hio_fmttobcstr(hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", cgi->task_req_version.major, cgi->task_req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
if (cgi_write_to_client(cgi, msgbuf, msglen) <= -1) goto oops;
|
||||
cgi->ever_attempted_to_write_to_client = 0; /* reset this as it's polluted for 100 continue */
|
||||
}
|
||||
|
@ -34,8 +34,6 @@ struct fcgi_t
|
||||
|
||||
hio_dev_sck_t* csck;
|
||||
hio_svc_htts_cli_t* client;
|
||||
hio_http_method_t req_method;
|
||||
hio_http_version_t req_version; /* client request */
|
||||
|
||||
unsigned int over: 4; /* must be large enough to accomodate FCGI_OVER_ALL */
|
||||
unsigned int keep_alive: 1;
|
||||
@ -145,12 +143,12 @@ static int fcgi_send_final_status_to_client (fcgi_t* fcgi, int status_code, int
|
||||
|
||||
if (!force_close) force_close = !fcgi->keep_alive;
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\nConnection: %hs\r\n",
|
||||
fcgi->req_version.major, fcgi->req_version.minor,
|
||||
fcgi->task_req_version.major, fcgi->task_req_version.minor,
|
||||
status_code, status_msg,
|
||||
cli->htts->server_name, dtbuf,
|
||||
(force_close? "close": "keep-alive")) == (hio_oow_t)-1) return -1;
|
||||
|
||||
if (fcgi->req_method == HIO_HTTP_HEAD)
|
||||
if (fcgi->task_req_method == HIO_HTTP_HEAD)
|
||||
{
|
||||
if (status_code != HIO_HTTP_STATUS_OK) content_len = 0;
|
||||
status_msg = "";
|
||||
@ -275,7 +273,7 @@ static void fcgi_on_kill (hio_svc_htts_task_t* task)
|
||||
/* [NOTE]
|
||||
* 1. if hio_svc_htts_task_kill() is called, fcgi->peer, fcgi->peer_htrd, fcgi->csck,
|
||||
* fcgi->client may not not null.
|
||||
* 2. this call-back function doesn't decrement the reference count on fcgi because
|
||||
* 2. this callback function doesn't decrement the reference count on fcgi because
|
||||
* this is the fcgi destruction call-back.
|
||||
*/
|
||||
|
||||
@ -476,7 +474,7 @@ static int peer_htrd_peek (hio_htrd_t* htrd, hio_htre_t* req)
|
||||
|
||||
hio_svc_htts_fmtgmtime (cli->htts, HIO_NULL, dtbuf, HIO_COUNTOF(dtbuf));
|
||||
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d ", fcgi->req_version.major, fcgi->req_version.minor) == (hio_oow_t)-1) return -1;
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d ", fcgi->task_req_version.major, fcgi->task_req_version.minor) == (hio_oow_t)-1) return -1;
|
||||
if (status_line)
|
||||
{
|
||||
if (hio_becs_fcat(cli->sbuf, "%hs\r\n", status_line) == (hio_oow_t)-1) return -1;
|
||||
@ -1037,7 +1035,7 @@ static int setup_for_expect100 (fcgi_t* fcgi, hio_htre_t* req, int options)
|
||||
hio_bch_t msgbuf[64];
|
||||
hio_oow_t msglen;
|
||||
|
||||
msglen = hio_fmttobcstr(fcgi->htts->hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", fcgi->req_version.major, fcgi->req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
msglen = hio_fmttobcstr(fcgi->htts->hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", fcgi->task_req_version.major, fcgi->task_req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
if (fcgi_write_to_client(fcgi, msgbuf, msglen) <= -1) return -1;
|
||||
fcgi->ever_attempted_to_write_to_client = 0; /* reset this as it's polluted for 100 continue */
|
||||
}
|
||||
@ -1115,13 +1113,11 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
||||
goto oops;
|
||||
}
|
||||
|
||||
fcgi = (fcgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*fcgi), fcgi_on_kill);
|
||||
fcgi = (fcgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*fcgi), fcgi_on_kill, req);
|
||||
if (HIO_UNLIKELY(!fcgi)) goto oops;
|
||||
|
||||
/*fcgi->num_pending_writes_to_client = 0;
|
||||
fcgi->num_pending_writes_to_peer = 0;*/
|
||||
fcgi->req_method = hio_htre_getqmethodtype(req);
|
||||
fcgi->req_version = *hio_htre_getversion(req);
|
||||
fcgi->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &fcgi->req_content_length);
|
||||
|
||||
bind_task_to_client (fcgi, csck);
|
||||
|
@ -69,8 +69,6 @@ struct file_t
|
||||
|
||||
hio_dev_sck_t* csck;
|
||||
hio_svc_htts_cli_t* client;
|
||||
hio_http_version_t req_version; /* client request */
|
||||
hio_http_method_t req_method;
|
||||
hio_bch_t* req_qpath;
|
||||
|
||||
unsigned int over: 4; /* must be large enough to accomodate FILE_OVER_ALL */
|
||||
@ -151,12 +149,12 @@ static int file_send_final_status_to_client (file_t* file, int status_code, int
|
||||
|
||||
if (!force_close) force_close = !file->keep_alive;
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\nConnection: %hs\r\n",
|
||||
file->req_version.major, file->req_version.minor,
|
||||
file->task_req_version.major, file->task_req_version.minor,
|
||||
status_code, status_msg,
|
||||
cli->htts->server_name, dtbuf,
|
||||
(force_close? "close": "keep-alive")) == (hio_oow_t)-1) return -1;
|
||||
|
||||
if (file->req_method == HIO_HTTP_HEAD)
|
||||
if (file->task_req_method == HIO_HTTP_HEAD)
|
||||
{
|
||||
if (status_code != HIO_HTTP_STATUS_OK) content_len = 0;
|
||||
status_msg = "";
|
||||
@ -264,7 +262,7 @@ static int file_write_to_peer (file_t* file, const void* data, hio_iolen_t dlen)
|
||||
else
|
||||
{
|
||||
hio_iolen_t pos, rem, n;
|
||||
if (file->req_method == HIO_HTTP_GET) return 0;
|
||||
if (file->task_req_method == HIO_HTTP_GET) return 0;
|
||||
if (file->peer <= -1) return 0; /* peer open proabably failed */
|
||||
|
||||
/* TODO: async file io -> create a file device?? */
|
||||
@ -437,7 +435,7 @@ static int file_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wr
|
||||
HIO_ASSERT (hio, file->num_pending_writes_to_client > 0);
|
||||
file->num_pending_writes_to_client--;
|
||||
|
||||
if (file->req_method == HIO_HTTP_GET)
|
||||
if (file->task_req_method == HIO_HTTP_GET)
|
||||
file_send_contents_to_client (file);
|
||||
|
||||
if ((file->over & FILE_OVER_READ_FROM_PEER) && file->num_pending_writes_to_client <= 0)
|
||||
@ -466,7 +464,7 @@ static int file_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
|
||||
/* indicate EOF to the client peer */
|
||||
if (file_write_to_peer(file, HIO_NULL, 0) <= -1) return -1;
|
||||
|
||||
if (file->req_method != HIO_HTTP_GET)
|
||||
if (file->task_req_method != HIO_HTTP_GET)
|
||||
{
|
||||
if (file_send_final_status_to_client(file, HIO_HTTP_STATUS_OK, 0, 0) <= -1) return -1;
|
||||
}
|
||||
@ -509,7 +507,7 @@ static int file_send_header_to_client (file_t* file, int status_code, int force_
|
||||
if (status_code == HIO_HTTP_STATUS_OK && file->total_size != content_length) status_code = HIO_HTTP_STATUS_PARTIAL_CONTENT;
|
||||
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %s\r\nConnection: %hs\r\nAccept-Ranges: bytes\r\n",
|
||||
file->req_version.major, file->req_version.minor,
|
||||
file->task_req_version.major, file->task_req_version.minor,
|
||||
status_code, hio_http_status_to_bcstr(status_code),
|
||||
cli->htts->server_name, dtbuf,
|
||||
(force_close? "close": "keep-alive")) == (hio_oow_t)-1) return -1;
|
||||
@ -518,7 +516,7 @@ static int file_send_header_to_client (file_t* file, int status_code, int force_
|
||||
if (mime_type && mime_type[0] != '\0' &&
|
||||
hio_becs_fcat(cli->sbuf, "Content-Type: %hs\r\n", mime_type) == (hio_oow_t)-1) return -1;
|
||||
|
||||
if ((file->req_method == HIO_HTTP_GET || file->req_method == HIO_HTTP_HEAD) &&
|
||||
if ((file->task_req_method == HIO_HTTP_GET || file->task_req_method == HIO_HTTP_HEAD) &&
|
||||
hio_becs_fcat(cli->sbuf, "ETag: %hs\r\n", file->peer_etag) == (hio_oow_t)-1) return -1;
|
||||
|
||||
if (status_code == HIO_HTTP_STATUS_PARTIAL_CONTENT &&
|
||||
@ -792,7 +790,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
||||
actual_file = hio_svc_htts_dupmergepaths(htts, docroot, filepath);
|
||||
if (HIO_UNLIKELY(!actual_file)) goto oops;
|
||||
|
||||
file = (file_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*file), file_on_kill);
|
||||
file = (file_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*file), file_on_kill, req);
|
||||
if (HIO_UNLIKELY(!file)) goto oops;
|
||||
|
||||
file->options = options;
|
||||
@ -800,8 +798,6 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
||||
file->sendfile_ok = hio_dev_sck_sendfileok(csck);
|
||||
/*file->num_pending_writes_to_client = 0;
|
||||
file->num_pending_writes_to_peer = 0;*/
|
||||
file->req_version = *hio_htre_getversion(req);
|
||||
file->req_method = hio_htre_getqmethodtype(req);
|
||||
file->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &file->req_content_length);
|
||||
file->req_qpath = req_qpath;
|
||||
req_qpath = HIO_NULL; /* delegated to the file task */
|
||||
@ -840,12 +836,12 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
||||
if (!(options & HIO_SVC_HTTS_FILE_NO_100_CONTINUE) &&
|
||||
hio_comp_http_version_numbers(&req->version, 1, 1) >= 0 &&
|
||||
(file->req_content_length_unlimited || file->req_content_length > 0) &&
|
||||
(file->req_method != HIO_HTTP_GET && file->req_method != HIO_HTTP_HEAD))
|
||||
(file->task_req_method != HIO_HTTP_GET && file->task_req_method != HIO_HTTP_HEAD))
|
||||
{
|
||||
hio_bch_t msgbuf[64];
|
||||
hio_oow_t msglen;
|
||||
|
||||
msglen = hio_fmttobcstr(hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", file->req_version.major, file->req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
msglen = hio_fmttobcstr(hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", file->task_req_version.major, file->task_req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
if (file_write_to_client(file, msgbuf, msglen) <= -1) goto oops;
|
||||
file->ever_attempted_to_write_to_client = 0; /* reset this as it's polluted for 100 continue */
|
||||
}
|
||||
@ -906,7 +902,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
||||
file->res_mode_to_cli = FILE_RES_MODE_CLOSE;
|
||||
}
|
||||
|
||||
switch (file->req_method)
|
||||
switch (file->task_req_method)
|
||||
{
|
||||
case HIO_HTTP_GET:
|
||||
case HIO_HTTP_HEAD:
|
||||
@ -920,7 +916,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
||||
}
|
||||
if (process_range_header(file, req, &status_code) <= -1) goto done_with_status_code;
|
||||
|
||||
if (HIO_LIKELY(file->req_method == HIO_HTTP_GET))
|
||||
if (HIO_LIKELY(file->task_req_method == HIO_HTTP_GET))
|
||||
{
|
||||
if (file->etag_match)
|
||||
{
|
||||
|
@ -653,7 +653,7 @@ int hio_svc_htts_getsockaddr (hio_svc_htts_t* htts, hio_oow_t idx, hio_skad_t* s
|
||||
*
|
||||
* you can pass sizeof(my_task_t) to hio_svc_htts_task_make()
|
||||
*/
|
||||
hio_svc_htts_task_t* hio_svc_htts_task_make (hio_svc_htts_t* htts, hio_oow_t task_size, hio_svc_htts_task_on_kill_t on_kill)
|
||||
hio_svc_htts_task_t* hio_svc_htts_task_make (hio_svc_htts_t* htts, hio_oow_t task_size, hio_svc_htts_task_on_kill_t on_kill, hio_htre_t* req)
|
||||
{
|
||||
hio_t* hio = htts->hio;
|
||||
hio_svc_htts_task_t* task;
|
||||
@ -671,6 +671,8 @@ hio_svc_htts_task_t* hio_svc_htts_task_make (hio_svc_htts_t* htts, hio_oow_t tas
|
||||
task->task_size = task_size;
|
||||
task->task_refcnt = 0;
|
||||
task->task_on_kill = on_kill;
|
||||
task->task_req_method = hio_htre_getqmethodtype(req);
|
||||
task->task_req_version = *hio_htre_getversion(req);
|
||||
|
||||
HIO_DEBUG2 (hio, "HTTS(%p) - allocated task %p\n", htts, task);
|
||||
return task;
|
||||
|
@ -68,8 +68,6 @@ struct thr_task_t
|
||||
hio_htrd_t* peer_htrd;
|
||||
hio_dev_sck_t* csck;
|
||||
hio_svc_htts_cli_t* client;
|
||||
hio_http_version_t req_version; /* client request */
|
||||
hio_http_method_t req_method;
|
||||
|
||||
unsigned int over: 4; /* must be large enough to accomodate THR_TASK_OVER_ALL */
|
||||
unsigned int keep_alive: 1;
|
||||
@ -159,12 +157,12 @@ static int thr_task_send_final_status_to_client (thr_task_t* thr_task, int statu
|
||||
|
||||
if (!force_close) force_close = !thr_task->keep_alive;
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\nConnection: %hs\r\n",
|
||||
thr_task->req_version.major, thr_task->req_version.minor,
|
||||
thr_task->task_req_version.major, thr_task->task_req_version.minor,
|
||||
status_code, status_msg,
|
||||
cli->htts->server_name, dtbuf,
|
||||
(force_close? "close": "keep-alive")) == (hio_oow_t)-1) return -1;
|
||||
|
||||
if (thr_task->req_method == HIO_HTTP_HEAD)
|
||||
if (thr_task->task_req_method == HIO_HTTP_HEAD)
|
||||
{
|
||||
if (status_code != HIO_HTTP_STATUS_OK) content_len = 0;
|
||||
status_msg = "";
|
||||
@ -499,7 +497,7 @@ static int thr_peer_htrd_peek (hio_htrd_t* htrd, hio_htre_t* req)
|
||||
hio_svc_htts_fmtgmtime (cli->htts, HIO_NULL, dtbuf, HIO_COUNTOF(dtbuf));
|
||||
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\n",
|
||||
thr_task->req_version.major, thr_task->req_version.minor,
|
||||
thr_task->task_req_version.major, thr_task->task_req_version.minor,
|
||||
status_code, hio_http_status_to_bcstr(status_code),
|
||||
cli->htts->server_name, dtbuf) == (hio_oow_t)-1) return -1;
|
||||
|
||||
@ -917,7 +915,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
||||
mi.on_write = thr_peer_on_write;
|
||||
mi.on_close = thr_peer_on_close;
|
||||
|
||||
thr_task = (thr_task_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*thr_task), thr_task_on_kill);
|
||||
thr_task = (thr_task_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*thr_task), thr_task_on_kill, req);
|
||||
if (HIO_UNLIKELY(!thr_task)) goto oops;
|
||||
|
||||
thr_task->options = options;
|
||||
@ -926,8 +924,6 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
||||
|
||||
/*thr_task->num_pending_writes_to_client = 0;
|
||||
thr_task->num_pending_writes_to_peer = 0;*/
|
||||
thr_task->req_method = hio_htre_getqmethodtype(req);
|
||||
thr_task->req_version = *hio_htre_getversion(req);
|
||||
thr_task->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &thr_task->req_content_length);
|
||||
|
||||
thr_task->client_org_on_read = csck->on_read;
|
||||
@ -1002,7 +998,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
||||
hio_bch_t msgbuf[64];
|
||||
hio_oow_t msglen;
|
||||
|
||||
msglen = hio_fmttobcstr(hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", thr_task->req_version.major, thr_task->req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
msglen = hio_fmttobcstr(hio, msgbuf, HIO_COUNTOF(msgbuf), "HTTP/%d.%d %d %hs\r\n\r\n", thr_task->task_req_version.major, thr_task->task_req_version.minor, HIO_HTTP_STATUS_CONTINUE, hio_http_status_to_bcstr(HIO_HTTP_STATUS_CONTINUE));
|
||||
if (thr_task_write_to_client(thr_task, msgbuf, msglen) <= -1) goto oops;
|
||||
thr_task->ever_attempted_to_write_to_client = 0; /* reset this as it's polluted for 100 continue */
|
||||
}
|
||||
|
@ -38,8 +38,6 @@ struct txt_t
|
||||
|
||||
hio_dev_sck_t* csck;
|
||||
hio_svc_htts_cli_t* client;
|
||||
hio_http_method_t req_method;
|
||||
hio_http_version_t req_version; /* client request */
|
||||
|
||||
unsigned int over: 2; /* must be large enough to accomodate TXT_OVER_ALL */
|
||||
unsigned int keep_alive: 1;
|
||||
@ -103,7 +101,7 @@ static int txt_send_final_status_to_client (txt_t* txt, int status_code, const h
|
||||
if (!force_close) force_close = !txt->keep_alive;
|
||||
|
||||
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\nConnection: %hs\r\n",
|
||||
txt->req_version.major, txt->req_version.minor,
|
||||
txt->task_req_version.major, txt->task_req_version.minor,
|
||||
status_code, hio_http_status_to_bcstr(status_code),
|
||||
cli->htts->server_name, dtbuf,
|
||||
(force_close? "close": "keep-alive")) == (hio_oow_t)-1) return -1;
|
||||
@ -111,7 +109,7 @@ static int txt_send_final_status_to_client (txt_t* txt, int status_code, const h
|
||||
if (content_text)
|
||||
{
|
||||
content_text_len = hio_count_bcstr(content_text);
|
||||
if (txt->req_method == HIO_HTTP_HEAD)
|
||||
if (txt->task_req_method == HIO_HTTP_HEAD)
|
||||
{
|
||||
if (status_code != HIO_HTTP_STATUS_OK) content_text_len = 0;
|
||||
content_text = "";
|
||||
@ -334,13 +332,11 @@ int hio_svc_htts_dotxt (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
||||
HIO_ASSERT (hio, hio_htre_getcontentlen(req) == 0);
|
||||
HIO_ASSERT (hio, cli->sck == csck);
|
||||
|
||||
txt = (txt_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*txt), txt_on_kill);
|
||||
txt = (txt_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*txt), txt_on_kill, req);
|
||||
if (HIO_UNLIKELY(!txt)) goto oops;
|
||||
|
||||
txt->options = options;
|
||||
/*txt->num_pending_writes_to_client = 0;*/
|
||||
txt->req_method = hio_htre_getqmethodtype(req);
|
||||
txt->req_version = *hio_htre_getversion(req);
|
||||
txt->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &txt->req_content_length);
|
||||
|
||||
txt->csck = csck;
|
||||
|
Loading…
Reference in New Issue
Block a user