minor fix in hio_dev_sck_sendfileok()

This commit is contained in:
hyung-hwan 2022-06-22 13:14:35 +00:00
parent 8273f0127a
commit d4eed93ac9
4 changed files with 24 additions and 4 deletions

View File

@ -974,9 +974,9 @@ if (hio_htre_getcontentlen(req) > 0)
else if (hio_comp_bcstr_limited(qpath, "/txt/", 5, 1) == 0) 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, 200, "text/plain", qpath);
else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0) else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0)
x = hio_svc_htts_docgi(htts, csck, req, "", hio_htre_getqpath(req)); x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4);
else else
x = hio_svc_htts_dofile(htts, csck, req, "", hio_htre_getqpath(req), "text/plain"); x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain");
if (x <= -1) goto oops; if (x <= -1) goto oops;
} }
#if 0 #if 0

View File

@ -203,9 +203,9 @@ if (hio_htre_getcontentlen(req) > 0)
else if (hio_comp_bcstr_limited(qpath, "/txt/", 5, 1) == 0) 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, 200, "text/plain", qpath);
else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0) else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0)
x = hio_svc_htts_docgi(htts, csck, req, "", hio_htre_getqpath(req)); x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4);
else else
x = hio_svc_htts_dofile(htts, csck, req, "", hio_htre_getqpath(req), "text/plain"); x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain");
if (x <= -1) goto oops; if (x <= -1) goto oops;
} }
#if 0 #if 0

View File

@ -32,6 +32,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h> /* setenv, clearenv */ #include <stdlib.h> /* setenv, clearenv */
#if defined(HAVE_CRT_EXTERNS_H)
# include <crt_externs.h> /* _NSGetEnviron */
#endif
#define CGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH #define CGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH
enum cgi_res_mode_t enum cgi_res_mode_t
@ -830,6 +834,12 @@ static int cgi_peer_on_fork (hio_dev_pro_t* pro, void* fork_ctx)
lang = hio_dupbcstr(hio, getenv("LANG"), HIO_NULL); lang = hio_dupbcstr(hio, getenv("LANG"), HIO_NULL);
#if defined(HAVE_CLEARENV) #if defined(HAVE_CLEARENV)
clearenv (); clearenv ();
#elif defined(HAVE_CRT_EXTERNS_H)
{
char** environ = *_NSGetEnviron();
if (environ) environ[0] = '\0';
}
#else #else
{ {
extern char** environ; extern char** environ;

View File

@ -2591,9 +2591,19 @@ int hio_dev_sck_shutdown (hio_dev_sck_t* dev, int how)
int hio_dev_sck_sendfileok (hio_dev_sck_t* dev) int hio_dev_sck_sendfileok (hio_dev_sck_t* dev)
{ {
#if defined(USE_SSL) #if defined(USE_SSL)
#if defined(HAVE_SENDFILE)
/* unable to use sendfile over ssl */
return !(dev->ssl); return !(dev->ssl);
#else #else
/* no send file implementation */
return 0;
#endif
#else
#if defined(HAVE_SENDFILE)
return 1; return 1;
#else
return 0;
#endif
#endif #endif
} }