pesi.activate: Set filters through VRT

this also fixes a build issue introduced by Varnish-Cache
13cf51e70c00b912ce39110d7eff50ccc01b7bb9
parent ad7e2b1b
......@@ -31,6 +31,7 @@
#include "cache/cache_varnishd.h"
#include <vcl.h>
#include <vrt_obj.h>
#include <vtim.h>
#include "vcc_pesi_if.h"
......@@ -167,36 +168,13 @@ vmod_pool(VRT_CTX, VCL_INT min, VCL_INT max, VCL_DURATION max_age)
poolparam.max_age = max_age;
}
/*
* pesi_filter_on_ws() and pesi_resp_default_filter_list()
* taken from cache_vrt_filter.c
*
*/
typedef void pesi_filter_list_t(void *, struct vsb *vsb);
static const char *
pesi_filter_on_ws(struct ws *ws, pesi_filter_list_t *func, void *arg)
{
struct vsb vsb[1];
const char *p;
AN(func);
AN(arg);
WS_VSB_new(vsb, ws);
func(arg, vsb);
p = WS_VSB_finish(vsb, ws, NULL);
if (p == NULL)
p = "";
return (p);
}
static void v_matchproto_(pesi_filter_list_t)
pesi_resp_default_filter_list(void *arg, struct vsb *vsb)
static void
pesi_filters(const struct req *req, struct strands *s)
{
struct req *req;
CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(s);
AZ(s->n);
/*
* the req->resp_len check has been removed because it does not work for
......@@ -207,39 +185,33 @@ pesi_resp_default_filter_list(void *arg, struct vsb *vsb)
if (!req->disable_esi && /* req->resp_len != 0 && */
ObjHasAttr(req->wrk, req->objcore, OA_ESIDATA))
VSB_cat(vsb, " pesi");
s->p[s->n++] = " pesi";
if (cache_param->http_gzip_support &&
ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
!RFC2616_Req_Gzip(req->http))
VSB_cat(vsb, " gunzip");
s->p[s->n++] = " gunzip";
if (cache_param->http_range_support &&
http_GetStatus(req->resp) == 200 &&
http_GetHdr(req->http, H_Range, NULL))
VSB_cat(vsb, " range");
s->p[s->n++] = " range";
}
VCL_VOID
vmod_activate(VRT_CTX)
{
struct req *req;
const char *filters;
struct strands *s;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
assert(ctx->method == VCL_MET_DELIVER);
req = ctx->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
filters = pesi_filter_on_ws(req->ws,
pesi_resp_default_filter_list, req);
s = TOSTRANDS(3, NULL);
s->n = 0;
if (filters == NULL)
WS_MarkOverflow(req->ws);
else
req->filter_list = filters;
pesi_filters(ctx->req, s);
VRT_l_resp_filters(ctx, NULL, s);
}
static unsigned
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment