MEDIUM: filters: Replace filter_http_headers callback by an analyzer
This new analyzer will be called for each HTTP request/response, before the
parsing of the body. It is identified by AN_FLT_HTTP_HDRS.
Special care was taken about the following condition :
* the frontend is a TCP proxy
* filters are defined in the frontend section
* the selected backend is a HTTP proxy
So, this patch explicitly add AN_FLT_HTTP_HDRS analyzer on the request and the
response channels when the backend is a HTTP proxy and when there are filters
attatched on the stream.
This patch simplifies http_request_forward_body and http_response_forward_body
functions.
diff --git a/src/stream.c b/src/stream.c
index a274ea4..7c10158 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -755,6 +755,12 @@
}
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 (s->be->mode == PR_MODE_HTTP && HAS_FILTERS(s))
+ rep->analysers |= AN_FLT_HTTP_HDRS;
+
rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
if (req->flags & CF_WAKE_CONNECT) {
req->flags |= CF_WAKE_ONCE;
@@ -1854,6 +1860,12 @@
UPDATE_ANALYSERS(req->analysers, ana_list, ana_back, AN_REQ_STICKING_RULES);
}
+ if (ana_list & AN_FLT_HTTP_HDRS) {
+ if (!flt_analyze_http_headers(s, req, AN_FLT_HTTP_HDRS))
+ break;
+ UPDATE_ANALYSERS(req->analysers, ana_list, ana_back, AN_FLT_HTTP_HDRS);
+ }
+
if (ana_list & AN_FLT_XFER_DATA) {
if (!flt_xfer_data(s, req, AN_FLT_XFER_DATA))
break;
@@ -1980,6 +1992,12 @@
UPDATE_ANALYSERS(res->analysers, ana_list, ana_back, AN_RES_HTTP_PROCESS_BE);
}
+ if (ana_list & AN_FLT_HTTP_HDRS) {
+ if (!flt_analyze_http_headers(s, res, AN_FLT_HTTP_HDRS))
+ break;
+ UPDATE_ANALYSERS(res->analysers, ana_list, ana_back, AN_FLT_HTTP_HDRS);
+ }
+
if (ana_list & AN_FLT_XFER_DATA) {
if (!flt_xfer_data(s, res, AN_FLT_XFER_DATA))
break;