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/flt_http_comp.c b/src/flt_http_comp.c
index 5dacc90..b07065d 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -108,13 +108,16 @@
if (!strm_fe(s)->comp && !s->be->comp)
goto end;
- switch (an_bit) {
- case AN_RES_HTTP_PROCESS_BE:
+ if (an_bit == AN_FLT_HTTP_HDRS) {
+ if (!(chn->flags & CF_ISRESP))
+ select_compression_request_header(st, s, &s->txn->req);
+ else {
select_compression_response_header(st, s, &s->txn->rsp);
if (st->comp_algo)
st->sov = s->txn->rsp.sov;
- break;
+ }
}
+
end:
return 1;
}
@@ -146,19 +149,6 @@
}
static int
-comp_http_headers(struct stream *s, struct filter *filter,
- struct http_msg *msg)
-{
- struct comp_state *st = filter->ctx;
-
- if (strm_fe(s)->comp || s->be->comp) {
- if (!(msg->chn->flags & CF_ISRESP))
- select_compression_request_header(st, s, msg);
- }
- return 1;
-}
-
-static int
comp_http_data(struct stream *s, struct filter *filter, struct http_msg *msg)
{
struct comp_state *st = filter->ctx;
@@ -725,10 +715,9 @@
.channel_analyze = comp_analyze,
.channel_end_analyze = comp_end_analyze,
- .http_headers = comp_http_headers,
- .http_data = comp_http_data,
- .http_chunk_trailers = comp_http_chunk_trailers,
- .http_forward_data = comp_http_forward_data,
+ .http_data = comp_http_data,
+ .http_chunk_trailers = comp_http_chunk_trailers,
+ .http_forward_data = comp_http_forward_data,
};
static int