]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats/cache: Handle the header Expect when applets are registered
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 1 Mar 2019 10:36:26 +0000 (11:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Mar 2019 08:53:14 +0000 (09:53 +0100)
First of all, it is a way to handle 100-Continue for the cache without
duplicating code. Then, for the stats, it is no longer necessary to wait for the
request body.

src/proto_http.c
src/proto_htx.c

index 1d75b056a5ddc7a406e954a2f0142a0f34fceb48..bd6a15a8815664724feaf610f53d58cdeed3c0ac 100644 (file)
@@ -1314,12 +1314,8 @@ int http_handle_stats(struct stream *s, struct channel *req)
        if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD)
                appctx->st0 = STAT_HTTP_HEAD;
        else if (txn->meth == HTTP_METH_POST && (msg->flags & HTTP_MSGF_CNT_LEN)) {
-               if (appctx->ctx.stats.flags & STAT_ADMIN) {
-                       /* we'll need the request body, possibly after sending 100-continue */
-                       if (msg->msg_state < HTTP_MSG_DATA)
-                               req->analysers |= AN_REQ_HTTP_BODY;
+               if (appctx->ctx.stats.flags & STAT_ADMIN)
                        appctx->st0 = STAT_HTTP_POST;
-               }
                else {
                        /* POST without admin level */
                        appctx->ctx.stats.flags &= ~STAT_CHUNKED;
@@ -2649,6 +2645,8 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
                if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
                        _HA_ATOMIC_ADD(&sess->fe->fe_counters.intercepted_req, 1);
 
+               http_handle_expect_hdr(s, req, msg);
+
                if (!(s->flags & SF_ERR_MASK))      // this is not really an error but it is
                        s->flags |= SF_ERR_LOCAL;   // to mark that it comes from the proxy
                if (!(s->flags & SF_FINST_MASK))
@@ -2658,6 +2656,9 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
                req->analysers &= (AN_REQ_HTTP_BODY | AN_REQ_FLT_HTTP_HDRS | AN_REQ_FLT_END);
                req->analysers &= ~AN_REQ_FLT_XFER_DATA;
                req->analysers |= AN_REQ_HTTP_XFER_BODY;
+
+               req->flags |= CF_SEND_DONTWAIT;
+               s->flags |= SF_ASSIGNED;
                goto done;
        }
 
index 22ad491fe71b365c61c027b34acbea6d743f5f96..9a06419b1b8ff49b47d4539efb358fccdcb24ed5 100644 (file)
@@ -619,6 +619,9 @@ int htx_process_req_common(struct stream *s, struct channel *req, int an_bit, st
                if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
                        _HA_ATOMIC_ADD(&sess->fe->fe_counters.intercepted_req, 1);
 
+               if (htx_handle_expect_hdr(s, htx, msg) == -1)
+                       goto return_bad_req;
+
                if (!(s->flags & SF_ERR_MASK))      // this is not really an error but it is
                        s->flags |= SF_ERR_LOCAL;   // to mark that it comes from the proxy
                if (!(s->flags & SF_FINST_MASK))
@@ -628,6 +631,9 @@ int htx_process_req_common(struct stream *s, struct channel *req, int an_bit, st
                req->analysers &= (AN_REQ_HTTP_BODY | AN_REQ_FLT_HTTP_HDRS | AN_REQ_FLT_END);
                req->analysers &= ~AN_REQ_FLT_XFER_DATA;
                req->analysers |= AN_REQ_HTTP_XFER_BODY;
+
+               req->flags |= CF_SEND_DONTWAIT;
+               s->flags |= SF_ASSIGNED;
                goto done;
        }
 
@@ -4916,12 +4922,8 @@ static int htx_handle_stats(struct stream *s, struct channel *req)
        if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD)
                appctx->st0 = STAT_HTTP_HEAD;
        else if (txn->meth == HTTP_METH_POST) {
-               if (appctx->ctx.stats.flags & STAT_ADMIN) {
-                       /* we'll need the request body, possibly after sending 100-continue */
-                       if (msg->msg_state < HTTP_MSG_DATA)
-                               req->analysers |= AN_REQ_HTTP_BODY;
+               if (appctx->ctx.stats.flags & STAT_ADMIN)
                        appctx->st0 = STAT_HTTP_POST;
-               }
                else {
                        /* POST without admin level */
                        appctx->ctx.stats.flags &= ~STAT_CHUNKED;