deleted QSE_HTTPD_SERVERSTD_EXPECT100 and improved 'Expect:' handling to return '417 Expectation Failed' for unknown expecttion
This commit is contained in:
parent
d5603febaa
commit
433b0da96d
@ -427,11 +427,6 @@ static int query_server (
|
|||||||
ssl->keyfile = server_xtn->scfg[SCFG_SSLKEYFILE];
|
ssl->keyfile = server_xtn->scfg[SCFG_SSLKEYFILE];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (code == QSE_HTTPD_SERVERSTD_EXPECT100)
|
|
||||||
{
|
|
||||||
*(int*)result = 100;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req)
|
if (req)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,8 @@ struct qse_htre_t
|
|||||||
#define QSE_HTRE_ATTR_CHUNKED (1 << 0)
|
#define QSE_HTRE_ATTR_CHUNKED (1 << 0)
|
||||||
#define QSE_HTRE_ATTR_LENGTH (1 << 1)
|
#define QSE_HTRE_ATTR_LENGTH (1 << 1)
|
||||||
#define QSE_HTRE_ATTR_KEEPALIVE (1 << 2)
|
#define QSE_HTRE_ATTR_KEEPALIVE (1 << 2)
|
||||||
#define QSE_HTRE_ATTR_EXPECT100 (1 << 3)
|
#define QSE_HTRE_ATTR_EXPECT (1 << 3)
|
||||||
|
#define QSE_HTRE_ATTR_EXPECT100 (1 << 4)
|
||||||
int flags;
|
int flags;
|
||||||
qse_size_t content_length;
|
qse_size_t content_length;
|
||||||
const qse_mchar_t* status; /* for cgi */
|
const qse_mchar_t* status; /* for cgi */
|
||||||
|
@ -99,7 +99,6 @@ struct qse_httpd_serverstd_ssl_t
|
|||||||
enum qse_httpd_serverstd_query_code_t
|
enum qse_httpd_serverstd_query_code_t
|
||||||
{
|
{
|
||||||
QSE_HTTPD_SERVERSTD_SSL, /* qse_httpd_serverstd_ssl_t */
|
QSE_HTTPD_SERVERSTD_SSL, /* qse_httpd_serverstd_ssl_t */
|
||||||
QSE_HTTPD_SERVERSTD_EXPECT100, /* int (http error code) */
|
|
||||||
|
|
||||||
QSE_HTTPD_SERVERSTD_NAME, /* const qse_mchar_t* */
|
QSE_HTTPD_SERVERSTD_NAME, /* const qse_mchar_t* */
|
||||||
QSE_HTTPD_SERVERSTD_ROOT, /* qse_httpd_serverstd_root_t */
|
QSE_HTTPD_SERVERSTD_ROOT, /* qse_httpd_serverstd_root_t */
|
||||||
|
@ -70,7 +70,7 @@ int qse_mbscasecmp (const qse_mchar_t* s1, const qse_mchar_t* s2)
|
|||||||
while (QSE_TOMUPPER(*s1) == QSE_TOMUPPER(*s2))
|
while (QSE_TOMUPPER(*s1) == QSE_TOMUPPER(*s2))
|
||||||
{
|
{
|
||||||
if (*s1 == QSE_C('\0')) return 0;
|
if (*s1 == QSE_C('\0')) return 0;
|
||||||
s1++, s2++;
|
s1++; s2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (QSE_TOMUPPER(*s1) > QSE_TOMUPPER(*s2))? 1: -1;
|
return (QSE_TOMUPPER(*s1) > QSE_TOMUPPER(*s2))? 1: -1;
|
||||||
|
@ -574,11 +574,17 @@ static int capture_expect (qse_htrd_t* htrd, qse_htb_pair_t* pair)
|
|||||||
{
|
{
|
||||||
qse_htre_hdrval_t* val;
|
qse_htre_hdrval_t* val;
|
||||||
|
|
||||||
val = QSE_HTB_VPTR(pair);
|
/* Expect is included */
|
||||||
while (val->next) val = val->next;
|
htrd->re.attr.flags |= QSE_HTRE_ATTR_EXPECT;
|
||||||
|
|
||||||
if (qse_mbscmp (val->ptr, QSE_MT("100-continue")) == 0)
|
val = QSE_HTB_VPTR(pair);
|
||||||
htrd->re.attr.flags |= QSE_HTRE_ATTR_EXPECT100;
|
while (val)
|
||||||
|
{
|
||||||
|
/* Expect: 100-continue is included */
|
||||||
|
if (qse_mbscasecmp (val->ptr, QSE_MT("100-continue")) == 0)
|
||||||
|
htrd->re.attr.flags |= QSE_HTRE_ATTR_EXPECT100;
|
||||||
|
val = val->next;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -495,9 +495,9 @@ qse_printf (QSE_T("NORMAL REPLY 222222222222222222222 NORMAL REPLY\n"));
|
|||||||
}
|
}
|
||||||
/* end initial line */
|
/* end initial line */
|
||||||
|
|
||||||
if (!(proxy->httpd->opt.trait & QSE_HTTPD_PROXYNOVIA))
|
if (!(proxy->httpd->opt.trait & QSE_HTTPD_PROXYNOVIA) && qse_htre_getscodeval(res) != 100)
|
||||||
{
|
{
|
||||||
/* add the Via: header into the response */
|
/* add the Via: header into the response if it is not 100. */
|
||||||
if (qse_mbs_cat (proxy->res, QSE_MT("Via: ")) == (qse_size_t)-1 ||
|
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_httpd_getname (proxy->httpd)) == (qse_size_t)-1 ||
|
||||||
qse_mbs_cat (proxy->res, QSE_MT("\r\n")) == (qse_size_t)-1)
|
qse_mbs_cat (proxy->res, QSE_MT("\r\n")) == (qse_size_t)-1)
|
||||||
|
@ -1866,43 +1866,39 @@ if (qse_htre_getcontentlen(req) > 0)
|
|||||||
|
|
||||||
if (peek)
|
if (peek)
|
||||||
{
|
{
|
||||||
/*if (method != QSE_HTTP_POST && method != QSE_HTTP_PUT && method != QSE_HTTP_OPTIONS)*/
|
#if 0
|
||||||
if (method == QSE_HTTP_HEAD || method == QSE_HTTP_GET)
|
if (method == QSE_HTTP_HEAD || method == QSE_HTTP_GET)
|
||||||
{
|
{
|
||||||
/* i'll discard request contents if the method is HEAD or GET */
|
/* i'll discard request contents if the method is HEAD or GET */
|
||||||
qse_httpd_discardcontent (httpd, req);
|
qse_httpd_discardcontent (httpd, req);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if ((req->attr.flags & QSE_HTRE_ATTR_EXPECT100) &&
|
if ((req->attr.flags & QSE_HTRE_ATTR_EXPECT) &&
|
||||||
(req->version.major > 1 ||
|
(req->version.major > 1 ||
|
||||||
(req->version.major == 1 && req->version.minor >= 1)) &&
|
(req->version.major == 1 && req->version.minor >= 1)) &&
|
||||||
!content_received)
|
!content_received)
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
/* "Expect: 100-Continue" in the header, version 1.1 or higher,
|
/* "Expect" in the header, version 1.1 or higher,
|
||||||
* and no content received yet */
|
* and no content received yet.
|
||||||
|
* if the partial or complete content is already received,
|
||||||
|
* we don't need to send '100 continue'. */
|
||||||
|
|
||||||
if (server_xtn->query (httpd, client->server, req, QSE_NULL, QSE_HTTPD_SERVERSTD_EXPECT100, &code) <= -1) return -1;
|
if (req->attr.flags & QSE_HTRE_ATTR_EXPECT100)
|
||||||
|
|
||||||
/* TODO: determine if to return 100-continue or other errors */
|
|
||||||
if (code == 100)
|
|
||||||
{
|
{
|
||||||
|
/* "Expect: 100-continue" in the header */
|
||||||
if (qse_httpd_entaskcontinue (httpd, client, QSE_NULL, req) == QSE_NULL) return -1;
|
if (qse_httpd_entaskcontinue (httpd, client, QSE_NULL, req) == QSE_NULL) return -1;
|
||||||
}
|
}
|
||||||
else if (code == 417)
|
else
|
||||||
{
|
{
|
||||||
/* if expectation fails, the client must not send the contents.
|
/* if expectation fails, the client must not send the contents.
|
||||||
* however, some erroneous clients may do that.
|
* however, some erroneous clients may do that.
|
||||||
* calling qse_httpd_discardcontent() won't do any harms */
|
* calling qse_httpd_discardcontent() won't do any harms */
|
||||||
|
|
||||||
/*
|
|
||||||
if (qse_httpd_entaskexpectfailure (httpd, client, QSE_NULL, req) == QSE_NULL) return -1;
|
|
||||||
*/
|
|
||||||
qse_httpd_discardcontent (httpd, req);
|
qse_httpd_discardcontent (httpd, req);
|
||||||
|
task = qse_httpd_entaskerr (httpd, client, QSE_NULL, 417, req);
|
||||||
|
if (task == QSE_NULL) goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if 200, ignore "Expect: 100-Continue" */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2706,10 +2702,6 @@ static int query_server (
|
|||||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOENT);
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOENT);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case QSE_HTTPD_SERVERSTD_EXPECT100:
|
|
||||||
*(int*)result = 100;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QSE_HTTPD_SERVERSTD_NAME:
|
case QSE_HTTPD_SERVERSTD_NAME:
|
||||||
*(const qse_mchar_t**)result = QSE_NULL;
|
*(const qse_mchar_t**)result = QSE_NULL;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user