]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: filters/http-ana: Decide to filter HTTP headers in HTTP analysers
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Mar 2021 17:20:09 +0000 (18:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Apr 2021 09:06:48 +0000 (11:06 +0200)
It is just a small cleanup. AN_REQ_FLT_HTTP_HDRS and AN_RES_FLT_HTTP_HDRS
analysers are now set in HTTP analysers at the same place
AN_REQ_HTTP_XFER_BODY and AN_RES_HTTP_XFER_BODY are set.

src/cfgparse.c
src/http_ana.c
src/proxy.c
src/stream.c

index 0cffdbbf4a82b19204bfab179e6dfec2ce6b7d0e..2682fba3335e692de1c436915229a3fb28a1f792 100644 (file)
@@ -3207,10 +3207,6 @@ out_uri_auth_compat:
                        if (!LIST_ISEMPTY(&curproxy->filter_configs)) {
                                curproxy->fe_req_ana |= AN_REQ_FLT_START_FE | AN_REQ_FLT_XFER_DATA | AN_REQ_FLT_END;
                                curproxy->fe_rsp_ana |= AN_RES_FLT_START_FE | AN_RES_FLT_XFER_DATA | AN_RES_FLT_END;
-                               if (curproxy->mode == PR_MODE_HTTP) {
-                                       curproxy->fe_req_ana |= AN_REQ_FLT_HTTP_HDRS;
-                                       curproxy->fe_rsp_ana |= AN_RES_FLT_HTTP_HDRS;
-                               }
                        }
                }
 
@@ -3237,10 +3233,6 @@ out_uri_auth_compat:
                        if (!LIST_ISEMPTY(&curproxy->filter_configs)) {
                                curproxy->be_req_ana |= AN_REQ_FLT_START_BE | AN_REQ_FLT_XFER_DATA | AN_REQ_FLT_END;
                                curproxy->be_rsp_ana |= AN_RES_FLT_START_BE | AN_RES_FLT_XFER_DATA | AN_RES_FLT_END;
-                               if (curproxy->mode == PR_MODE_HTTP) {
-                                       curproxy->be_req_ana |= AN_REQ_FLT_HTTP_HDRS;
-                                       curproxy->be_rsp_ana |= AN_RES_FLT_HTTP_HDRS;
-                               }
                        }
                }
 
index a13c9468266b56ac484c3964a520793a104fea63..b0067c307a419122df4206aad785b615769bfb44 100644 (file)
@@ -452,6 +452,9 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
                if (!(s->flags & SF_FINST_MASK))
                        s->flags |= SF_FINST_R;
 
+               if (HAS_FILTERS(s))
+                       req->analysers |= AN_REQ_FLT_HTTP_HDRS;
+
                /* enable the minimally required analyzers to handle keep-alive and compression on the HTTP response */
                req->analysers &= (AN_REQ_HTTP_BODY | AN_REQ_FLT_HTTP_HDRS | AN_REQ_FLT_END);
                req->analysers &= ~AN_REQ_FLT_XFER_DATA;
@@ -777,6 +780,12 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
                }
        }
 
+       /* Filter the request headers if there are filters attached to the
+        * stream.
+        */
+       if (HAS_FILTERS(s))
+               req->analysers |= AN_REQ_FLT_HTTP_HDRS;
+
        /* If we have no server assigned yet and we're balancing on url_param
         * with a POST request, we may be interested in checking the body for
         * that parameter. This will be done in another analyser.
@@ -2071,6 +2080,12 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
        if (!http_eval_after_res_rules(s))
                goto return_int_err;
 
+       /* Filter the response headers if there are filters attached to the
+        * stream.
+        */
+       if (HAS_FILTERS(s))
+               rep->analysers |= AN_RES_FLT_HTTP_HDRS;
+
        /* Always enter in the body analyzer */
        rep->analysers &= ~AN_RES_FLT_XFER_DATA;
        rep->analysers |= AN_RES_HTTP_XFER_BODY;
index 234515ddda0ec346149554d714680ca0e58236c9..d044150c077901044559e9e0a7681b2e3b7c6601 100644 (file)
@@ -2153,11 +2153,6 @@ int stream_set_backend(struct stream *s, struct proxy *be)
                http_init_txn(s);
        }
 
-       /* Be sure to filter request headers if the backend is an HTTP proxy and
-        * if there are filters attached to the stream. */
-       if (s->be->mode == PR_MODE_HTTP && HAS_FILTERS(s))
-               s->req.analysers |= AN_REQ_FLT_HTTP_HDRS;
-
        if (s->txn) {
                /* If we chain a TCP frontend to an HTX backend, we must upgrade
                 * the client mux */
index c1ba9050d9c90ea1d8cbeaff4349f50a8e9a1e29..eb648077439706bfd2cc7578c9698e9d78320ec4 100644 (file)
@@ -933,11 +933,6 @@ static void back_establish(struct stream *s)
 
        rep->analysers |= strm_fe(s)->fe_rsp_ana | s->be->be_rsp_ana;
 
-       /* Be sure to filter response headers if the backend is an HTTP proxy
-        * and if there are filters attached to the stream. */
-       if (IS_HTX_STRM(s) && HAS_FILTERS(s))
-               rep->analysers |= AN_RES_FLT_HTTP_HDRS;
-
        si_rx_endp_more(si);
        rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
        if (objt_cs(si->end)) {