When a compression filter, request or response, is attached to a stream,
there was no special test to know if the filter will be usable, so when its
direction was not enabled or no algorithm was available for it on the proxy
that declared it.
Now the attach callback returns 0 when the direction is not enabled or when
the compression configuration has no algorithm for the filter's direction,
so the filter is not attached to the stream at all. Its per-stream state is
not allocated and its HTTP callbacks are never called; these filters were
already ignored by the http_headers callback, they are just not instantiated
anymore.
A NULL configuration is also tolerated, so that an implicit instance
inherited by a proxy without the matching capability can keep its metadata
without applicable options.
The check uses the compression options stored in the filter configuration by
the preceding change, and only inspects the proxy that declared the
filter. When the algorithms are configured on the other proxy, that proxy
also gets an implicit filter for the direction, so an instance with a local
algorithm remains attached to perform the compression. This also prepares
the filter instances, where the same options are shared by the legacy
configurations and the instances.
static int
comp_strm_init(struct stream *s, struct filter *filter)
{
+ struct comp *comp = FLT_CONF(filter);
struct comp_state *st;
+ if (filter->config->id == http_comp_req_flt_id &&
+ (!comp || !comp->algo_req || !(comp->flags & COMP_FL_DIR_REQ)))
+ return 0;
+ else if (filter->config->id == http_comp_res_flt_id &&
+ (!comp || !comp->algos_res || !(comp->flags & COMP_FL_DIR_RES)))
+ return 0;
+
st = pool_alloc(pool_head_comp_state);
if (st == NULL)
return -1;