enhanced the httpd proxy code to add 'Via:' if QSE_HTTPD_PROXYNOVIA is not set
This commit is contained in:
parent
4d8c02588f
commit
5777602a01
@ -1312,20 +1312,8 @@ static int load_config (qse_httpd_t* httpd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pair = qse_xli_findpairbyname (httpd_xtn->xli, QSE_NULL, QSE_T("default.name"));
|
if (httpd_xtn->dflcfg.xcfg[XCFG_NAME])
|
||||||
if (pair && pair->val->type == QSE_XLI_STR)
|
qse_httpd_setname (httpd, httpd_xtn->dflcfg.xcfg[XCFG_NAME]);
|
||||||
{
|
|
||||||
qse_mchar_t* name = qse_httpd_strtombsdup (httpd, ((qse_xli_str_t*)pair->val)->ptr);
|
|
||||||
if (name)
|
|
||||||
{
|
|
||||||
qse_httpd_setname (httpd, name);
|
|
||||||
qse_httpd_freemem (httpd, name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* TODO: warning */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close_config_file (httpd);
|
close_config_file (httpd);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -75,7 +75,8 @@ enum qse_httpd_trait_t
|
|||||||
QSE_HTTPD_CGIERRTONUL = (1 << 1),
|
QSE_HTTPD_CGIERRTONUL = (1 << 1),
|
||||||
QSE_HTTPD_CGINOCLOEXEC = (1 << 2),
|
QSE_HTTPD_CGINOCLOEXEC = (1 << 2),
|
||||||
QSE_HTTPD_CGINOCHUNKED = (1 << 3),
|
QSE_HTTPD_CGINOCHUNKED = (1 << 3),
|
||||||
QSE_HTTPD_LOGACT = (1 << 4)
|
QSE_HTTPD_PROXYNOVIA = (1 << 4),
|
||||||
|
QSE_HTTPD_LOGACT = (1 << 5)
|
||||||
};
|
};
|
||||||
typedef enum qse_httpd_trait_t qse_httpd_trait_t;
|
typedef enum qse_httpd_trait_t qse_httpd_trait_t;
|
||||||
|
|
||||||
@ -698,7 +699,7 @@ QSE_EXPORT void qse_httpd_setname (
|
|||||||
* pointer to the string used as the value for the server
|
* pointer to the string used as the value for the server
|
||||||
* header.
|
* header.
|
||||||
*/
|
*/
|
||||||
QSE_EXPORT qse_mchar_t* qse_httpd_getname (
|
QSE_EXPORT const qse_mchar_t* qse_httpd_getname (
|
||||||
qse_httpd_t* httpd
|
qse_httpd_t* httpd
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -495,6 +495,18 @@ qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY\n"));
|
|||||||
}
|
}
|
||||||
/* end initial line */
|
/* end initial line */
|
||||||
|
|
||||||
|
if (!(proxy->httpd->opt.trait & QSE_HTTPD_PROXYNOVIA))
|
||||||
|
{
|
||||||
|
/* add the Via: header into the response */
|
||||||
|
if (qse_mbs_cat (proxy->res, QSE_MT("Via: ")) == (qse_size_t)-1 ||
|
||||||
|
qse_mbs_cat (proxy->res, qse_httpd_getname (proxy->httpd)) == (qse_size_t)-1 ||
|
||||||
|
qse_mbs_cat (proxy->res, QSE_MT("\r\n")) == (qse_size_t)-1)
|
||||||
|
{
|
||||||
|
proxy->httpd->errnum = QSE_HTTPD_ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (proxy->resflags & PROXY_RES_PEER_LENGTH_FAKE)
|
if (proxy->resflags & PROXY_RES_PEER_LENGTH_FAKE)
|
||||||
{
|
{
|
||||||
qse_mchar_t buf[64];
|
qse_mchar_t buf[64];
|
||||||
@ -749,6 +761,15 @@ static int task_init_proxy (
|
|||||||
}
|
}
|
||||||
|
|
||||||
snatch_needed = 0;
|
snatch_needed = 0;
|
||||||
|
|
||||||
|
if (!(httpd->opt.trait & QSE_HTTPD_PROXYNOVIA))
|
||||||
|
{
|
||||||
|
/* add the Via: header into the request */
|
||||||
|
if (qse_mbs_cat (proxy->reqfwdbuf, QSE_MT("Via: ")) == (qse_size_t)-1 ||
|
||||||
|
qse_mbs_cat (proxy->reqfwdbuf, qse_httpd_getname (httpd)) == (qse_size_t)-1 ||
|
||||||
|
qse_mbs_cat (proxy->reqfwdbuf, QSE_MT("\r\n")) == (qse_size_t)-1) goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg->req->state & QSE_HTRE_DISCARDED)
|
if (arg->req->state & QSE_HTRE_DISCARDED)
|
||||||
{
|
{
|
||||||
/* no content to add */
|
/* no content to add */
|
||||||
@ -803,6 +824,7 @@ static int task_init_proxy (
|
|||||||
}
|
}
|
||||||
else if (arg->req->attr.flags & QSE_HTRE_ATTR_LENGTH)
|
else if (arg->req->attr.flags & QSE_HTRE_ATTR_LENGTH)
|
||||||
{
|
{
|
||||||
|
/* the Content-Length header field is contained in the request. */
|
||||||
qse_mchar_t buf[64];
|
qse_mchar_t buf[64];
|
||||||
qse_fmtuintmaxtombs (
|
qse_fmtuintmaxtombs (
|
||||||
buf, QSE_COUNTOF(buf),
|
buf, QSE_COUNTOF(buf),
|
||||||
|
@ -1330,7 +1330,7 @@ void qse_httpd_setname (qse_httpd_t* httpd, const qse_mchar_t* name)
|
|||||||
qse_mbsxcpy (httpd->sname, QSE_COUNTOF(httpd->sname), name);
|
qse_mbsxcpy (httpd->sname, QSE_COUNTOF(httpd->sname), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
qse_mchar_t* qse_httpd_getname (qse_httpd_t* httpd)
|
const qse_mchar_t* qse_httpd_getname (qse_httpd_t* httpd)
|
||||||
{
|
{
|
||||||
return httpd->sname;
|
return httpd->sname;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user