touched up some code
This commit is contained in:
parent
fc20cb22ea
commit
e8cef98c87
@ -2139,6 +2139,7 @@ static int prerewrite_url (qse_httpd_t* httpd, qse_httpd_client_t* client, qse_h
|
|||||||
|
|
||||||
httpd_xtn = qse_httpd_getxtnstd (httpd);
|
httpd_xtn = qse_httpd_getxtnstd (httpd);
|
||||||
|
|
||||||
|
printf ("PREREWRITING.....................\n");
|
||||||
/* TODO: override prerewrite url */
|
/* TODO: override prerewrite url */
|
||||||
return httpd_xtn->org_urs_prerewrite (httpd, client, req, host, url);
|
return httpd_xtn->org_urs_prerewrite (httpd, client, req, host, url);
|
||||||
}
|
}
|
||||||
|
@ -1041,6 +1041,17 @@ printf (">>>>>>>>>>>>>>>>>>>>>>>> [%s] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", proxy
|
|||||||
qse_mbs_cat (proxy->reqfwdbuf, qse_htre_getqparam(arg->req)) == (qse_size_t)-1) goto nomem_oops;
|
qse_mbs_cat (proxy->reqfwdbuf, qse_htre_getqparam(arg->req)) == (qse_size_t)-1) goto nomem_oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
/* KT FILTERING WORKAROUND POC. KT seems to check the Host: the first packet
|
||||||
|
* only.I add 1500 byte space octets between the URL and the HTTP version string.
|
||||||
|
* the header is likely to be placed in the second packet. it seems to work. */
|
||||||
|
qse_mchar_t spc[1500];
|
||||||
|
QSE_MEMSET (spc, QSE_MT(' '), QSE_COUNTOF(spc));
|
||||||
|
qse_mbs_ncat (proxy->reqfwdbuf, spc, QSE_COUNTOF(spc));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (qse_mbs_cat (proxy->reqfwdbuf, QSE_MT(" ")) == (qse_size_t)-1 ||
|
if (qse_mbs_cat (proxy->reqfwdbuf, QSE_MT(" ")) == (qse_size_t)-1 ||
|
||||||
qse_mbs_cat (proxy->reqfwdbuf, qse_htre_getverstr(arg->req)) == (qse_size_t)-1 ||
|
qse_mbs_cat (proxy->reqfwdbuf, qse_htre_getverstr(arg->req)) == (qse_size_t)-1 ||
|
||||||
qse_mbs_cat (proxy->reqfwdbuf, QSE_MT("\r\n")) == (qse_size_t)-1 ||
|
qse_mbs_cat (proxy->reqfwdbuf, QSE_MT("\r\n")) == (qse_size_t)-1 ||
|
||||||
|
@ -375,7 +375,7 @@ static qse_httpd_errnum_t direrr_to_errnum (qse_dir_errnum_t e)
|
|||||||
/* ------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------- */
|
||||||
|
|
||||||
static QSE_INLINE qse_ssize_t __send_file (
|
static QSE_INLINE qse_ssize_t __send_file (
|
||||||
qse_httpd_t* httpd, int out_fd, qse_ubi_t in_fd,
|
qse_httpd_t* httpd, qse_sck_hnd_t out_fd, qse_ubi_t in_fd,
|
||||||
qse_foff_t* offset, qse_size_t count)
|
qse_foff_t* offset, qse_size_t count)
|
||||||
{
|
{
|
||||||
/* TODO: os2 warp 4.5 has send_file. support it??? load it dynamically??? */
|
/* TODO: os2 warp 4.5 has send_file. support it??? load it dynamically??? */
|
||||||
@ -387,12 +387,14 @@ static QSE_INLINE qse_ssize_t __send_file (
|
|||||||
#elif defined(HAVE_SENDFILE) && defined(HAVE_SENDFILE64)
|
#elif defined(HAVE_SENDFILE) && defined(HAVE_SENDFILE64)
|
||||||
|
|
||||||
qse_ssize_t ret;
|
qse_ssize_t ret;
|
||||||
qse_ubi_t infd = qse_fio_gethandleasubi (in_fd.ptr);
|
qse_fio_hnd_t fh;
|
||||||
|
|
||||||
|
fh = qse_fio_gethandle (in_fd.ptr);
|
||||||
|
|
||||||
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
|
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
|
||||||
ret = sendfile64 (out_fd, infd.i, offset, count);
|
ret = sendfile64 (out_fd, fh, offset, count);
|
||||||
#else
|
#else
|
||||||
ret = sendfile (out_fd, infd.i, offset, count);
|
ret = sendfile (out_fd, fh, offset, count);
|
||||||
#endif
|
#endif
|
||||||
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
||||||
return ret;
|
return ret;
|
||||||
@ -400,20 +402,27 @@ static QSE_INLINE qse_ssize_t __send_file (
|
|||||||
#elif defined(HAVE_SENDFILE)
|
#elif defined(HAVE_SENDFILE)
|
||||||
|
|
||||||
qse_ssize_t ret;
|
qse_ssize_t ret;
|
||||||
qse_ubi_t infd = qse_fio_gethandleasubi (in_fd.ptr);
|
qse_fio_hnd_t fh;
|
||||||
ret = sendfile (out_fd, infd.i, offset, count);
|
|
||||||
|
fh = qse_fio_gethandle (in_fd.ptr);
|
||||||
|
ret = sendfile (out_fd, fh, offset, count);
|
||||||
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
#elif defined(HAVE_SENDFILE64)
|
#elif defined(HAVE_SENDFILE64)
|
||||||
|
|
||||||
qse_ssize_t ret;
|
qse_ssize_t ret;
|
||||||
qse_ubi_t infd = qse_fio_gethandleasubi (in_fd.ptr);
|
qse_fio_hnd_t fh;
|
||||||
ret = sendfile64 (out_fd, in_fd.i, offset, count);
|
|
||||||
|
fh = qse_fio_gethandle (in_fd.ptr);
|
||||||
|
ret = sendfile64 (out_fd, fh, offset, count);
|
||||||
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
#elif defined(HAVE_SENDFILEV) || defined(HAVE_SENDFILEV64)
|
#elif defined(HAVE_SENDFILEV) || defined(HAVE_SENDFILEV64)
|
||||||
|
|
||||||
|
/* solaris */
|
||||||
|
|
||||||
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
|
#if !defined(_LP64) && (QSE_SIZEOF_VOID_P<8) && defined(HAVE_SENDFILE64)
|
||||||
struct sendfilevec64 vec;
|
struct sendfilevec64 vec;
|
||||||
#else
|
#else
|
||||||
@ -1547,29 +1556,32 @@ static int file_purge (qse_httpd_t* httpd, const qse_mchar_t* path)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static qse_fio_t* __open_file (qse_httpd_t* httpd, const qse_mchar_t* path, int fio_flags, int fio_mode)
|
||||||
|
{
|
||||||
|
qse_fio_t* fio;
|
||||||
|
|
||||||
|
fio = qse_httpd_allocmem (httpd, QSE_SIZEOF(*fio));
|
||||||
|
if (fio == QSE_NULL) return QSE_NULL;
|
||||||
|
|
||||||
|
if (qse_fio_init (fio, httpd->mmgr, (const qse_char_t*)path, fio_flags, fio_mode) <= -1)
|
||||||
|
{
|
||||||
|
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(fio)));
|
||||||
|
qse_httpd_freemem (httpd, fio);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fio;
|
||||||
|
}
|
||||||
|
|
||||||
static int file_ropen (
|
static int file_ropen (
|
||||||
qse_httpd_t* httpd, const qse_mchar_t* path, qse_ubi_t* handle)
|
qse_httpd_t* httpd, const qse_mchar_t* path, qse_ubi_t* handle)
|
||||||
{
|
{
|
||||||
qse_fio_t* fio;
|
qse_fio_t* fio;
|
||||||
|
|
||||||
fio = QSE_MMGR_ALLOC (httpd->mmgr, QSE_SIZEOF(*fio));
|
fio = __open_file (httpd, path, QSE_FIO_READ | QSE_FIO_MBSPATH, 0);
|
||||||
if (fio == QSE_NULL)
|
if (fio == QSE_NULL) return -1;
|
||||||
{
|
|
||||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qse_fio_init (
|
|
||||||
fio, httpd->mmgr, (const qse_char_t*)path,
|
|
||||||
QSE_FIO_READ | QSE_FIO_MBSPATH, 0) <= -1)
|
|
||||||
{
|
|
||||||
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(fio)));
|
|
||||||
QSE_MMGR_FREE (httpd->mmgr, fio);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle->ptr = fio;
|
handle->ptr = fio;
|
||||||
|
|
||||||
if (httpd->opt.trait & QSE_HTTPD_LOGACT)
|
if (httpd->opt.trait & QSE_HTTPD_LOGACT)
|
||||||
{
|
{
|
||||||
qse_httpd_act_t msg;
|
qse_httpd_act_t msg;
|
||||||
@ -1579,8 +1591,8 @@ static int file_ropen (
|
|||||||
qse_mbsxcpy (&msg.u.mdbgmsg[pos], QSE_COUNTOF(msg.u.mdbgmsg) - pos, path);
|
qse_mbsxcpy (&msg.u.mdbgmsg[pos], QSE_COUNTOF(msg.u.mdbgmsg) - pos, path);
|
||||||
httpd->opt.rcb.logact (httpd, &msg);
|
httpd->opt.rcb.logact (httpd, &msg);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int file_wopen (
|
static int file_wopen (
|
||||||
@ -1589,25 +1601,10 @@ static int file_wopen (
|
|||||||
{
|
{
|
||||||
qse_fio_t* fio;
|
qse_fio_t* fio;
|
||||||
|
|
||||||
fio = QSE_MMGR_ALLOC (httpd->mmgr, QSE_SIZEOF(*fio));
|
fio = __open_file (httpd, path, QSE_FIO_WRITE | QSE_FIO_CREATE | QSE_FIO_TRUNCATE | QSE_FIO_MBSPATH, 0644);
|
||||||
if (fio == QSE_NULL)
|
if (fio == QSE_NULL) return -1;
|
||||||
{
|
|
||||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOMEM);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qse_fio_init (
|
|
||||||
fio, httpd->mmgr, (const qse_char_t*)path,
|
|
||||||
QSE_FIO_WRITE | QSE_FIO_CREATE |
|
|
||||||
QSE_FIO_TRUNCATE | QSE_FIO_MBSPATH, 0644) <= -1)
|
|
||||||
{
|
|
||||||
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(fio)));
|
|
||||||
QSE_MMGR_FREE (httpd->mmgr, fio);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle->ptr = fio;
|
handle->ptr = fio;
|
||||||
|
|
||||||
if (httpd->opt.trait & QSE_HTTPD_LOGACT)
|
if (httpd->opt.trait & QSE_HTTPD_LOGACT)
|
||||||
{
|
{
|
||||||
qse_httpd_act_t msg;
|
qse_httpd_act_t msg;
|
||||||
@ -1624,12 +1621,11 @@ static int file_wopen (
|
|||||||
static void file_close (qse_httpd_t* httpd, qse_ubi_t handle)
|
static void file_close (qse_httpd_t* httpd, qse_ubi_t handle)
|
||||||
{
|
{
|
||||||
qse_fio_fini (handle.ptr);
|
qse_fio_fini (handle.ptr);
|
||||||
QSE_MMGR_FREE (httpd->mmgr, handle.ptr);
|
qse_httpd_freemem (httpd, handle.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static qse_ssize_t file_read (
|
static qse_ssize_t file_read (
|
||||||
qse_httpd_t* httpd, qse_ubi_t handle,
|
qse_httpd_t* httpd, qse_ubi_t handle, qse_mchar_t* buf, qse_size_t len)
|
||||||
qse_mchar_t* buf, qse_size_t len)
|
|
||||||
{
|
{
|
||||||
qse_ssize_t n;
|
qse_ssize_t n;
|
||||||
n = qse_fio_read (handle.ptr, buf, len);
|
n = qse_fio_read (handle.ptr, buf, len);
|
||||||
@ -1638,8 +1634,7 @@ static qse_ssize_t file_read (
|
|||||||
}
|
}
|
||||||
|
|
||||||
static qse_ssize_t file_write (
|
static qse_ssize_t file_write (
|
||||||
qse_httpd_t* httpd, qse_ubi_t handle,
|
qse_httpd_t* httpd, qse_ubi_t handle, const qse_mchar_t* buf, qse_size_t len)
|
||||||
const qse_mchar_t* buf, qse_size_t len)
|
|
||||||
{
|
{
|
||||||
qse_ssize_t n;
|
qse_ssize_t n;
|
||||||
n = qse_fio_write (handle.ptr, buf, len);
|
n = qse_fio_write (handle.ptr, buf, len);
|
||||||
|
Loading…
Reference in New Issue
Block a user