MINOR: filters/http-ana: Decide to filter HTTP headers in HTTP analysers

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.
This commit is contained in:
Christopher Faulet 2021-03-08 18:20:09 +01:00
parent 1bb6afa35d
commit c2ac5e4f27
4 changed files with 15 additions and 18 deletions

View File

@ -3207,10 +3207,6 @@ int check_config_validity()
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 @@ int check_config_validity()
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;
}
}
}

View 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;

View 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 */

View 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)) {