enabled the http file handler to accept POST, PUT, DELETE
This commit is contained in:
20
bin/t06.c
20
bin/t06.c
@@ -45,7 +45,7 @@ static void on_htts_thr_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf (fp, "Status: 200\r\n");
|
||||
fprintf (fp, "Status: %d\r\n", HIO_HTTP_STATUS_OK);
|
||||
fprintf (fp, "Content-Type: text/html\r\n\r\n");
|
||||
|
||||
fprintf (fp, "request path = %s\n", tfi->req_path);
|
||||
@@ -82,13 +82,13 @@ static void on_htts_thr2_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc
|
||||
sf = fopen(&tfi->req_path[5], "r");
|
||||
if (!sf)
|
||||
{
|
||||
fprintf (fp, "Status: 404\r\n\r\n");
|
||||
fprintf (fp, "Status: %d\r\n\r\n", HIO_HTTP_STATUS_NOT_FOUND);
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
fprintf (fp, "Status: 200\r\n");
|
||||
fprintf (fp, "Status: %d\r\n", HIO_HTTP_STATUS_OK);
|
||||
fprintf (fp, "Content-Type: text/html\r\n\r\n");
|
||||
|
||||
while (!feof(sf) && !ferror(sf))
|
||||
@@ -188,7 +188,7 @@ if (hio_htre_getcontentlen(req) > 0)
|
||||
hio_htre_discardcontent (req);
|
||||
/* 411 Length Required - can't keep alive. Force disconnect */
|
||||
req->flags &= ~HIO_HTRE_ATTR_KEEPALIVE; /* to cause sendstatus() to close */
|
||||
if (hio_svc_htts_sendstatus(htts, csck, req, 411, HIO_NULL) <= -1) goto oops;
|
||||
if (hio_svc_htts_sendstatus(htts, csck, req, HIO_HTTP_STATUS_LENGTH_REQUIRED, HIO_NULL) <= -1) goto oops;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -197,21 +197,21 @@ if (hio_htre_getcontentlen(req) > 0)
|
||||
const hio_bch_t* qpath = hio_htre_getqpath(req);
|
||||
int x;
|
||||
if (hio_comp_bcstr_limited(qpath, "/thr/", 5, 1) == 0)
|
||||
x = hio_svc_htts_dothr(htts, csck, req, on_htts_thr_request, HIO_NULL);
|
||||
x = hio_svc_htts_dothr(htts, csck, req, on_htts_thr_request, HIO_NULL, HIO_SVC_HTTS_THR_NO_100_CONTINUE);
|
||||
else if (hio_comp_bcstr_limited(qpath, "/thr2/", 6, 1) == 0)
|
||||
x = hio_svc_htts_dothr(htts, csck, req, on_htts_thr2_request, HIO_NULL);
|
||||
x = hio_svc_htts_dothr(htts, csck, req, on_htts_thr2_request, HIO_NULL, HIO_SVC_HTTS_THR_NO_100_CONTINUE);
|
||||
else if (hio_comp_bcstr_limited(qpath, "/txt/", 5, 1) == 0)
|
||||
x = hio_svc_htts_dotxt(htts, csck, req, 200, "text/plain", qpath);
|
||||
x = hio_svc_htts_dotxt(htts, csck, req, HIO_HTTP_STATUS_OK, "text/plain", qpath, 0);
|
||||
else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0)
|
||||
x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4);
|
||||
x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4, 0);
|
||||
else if (hio_comp_bcstr_limited(qpath, "/fcgi/", 5, 1) == 0)
|
||||
{
|
||||
hio_skad_t fcgis_addr;
|
||||
hio_bcstrtoskad(hio, "127.0.0.1:9000", &fcgis_addr);
|
||||
x = hio_svc_htts_dofcgi(htts, csck, req, &fcgis_addr);
|
||||
x = hio_svc_htts_dofcgi(htts, csck, req, &fcgis_addr, 0);
|
||||
}
|
||||
else
|
||||
x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain");
|
||||
x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain", 0);
|
||||
if (x <= -1) goto oops;
|
||||
}
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user