Adapt to post 7.0 filter API changes

parent b4f010e0
......@@ -304,13 +304,14 @@ static const struct vfp vfp_br, vfp_unbr;
/* init and fini methods for both br and unbr */
static enum vfp_status v_matchproto_(vfp_init_f)
vfp_br_init(struct vfp_ctx *ctx, struct vfp_entry *ent)
vfp_br_init(VRT_CTX, struct vfp_ctx *vc, struct vfp_entry *ent)
{
struct vbr *vbr;
const struct vfp_priv *priv;
const struct vbr_settings *settings;
CHECK_OBJ_NOTNULL(ctx, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ent, VFP_ENTRY_MAGIC);
AN(ent->vfp);
CAST_OBJ_NOTNULL(priv, ent->vfp->priv1, VFP_PRIV_MAGIC);
......@@ -321,19 +322,19 @@ vfp_br_init(struct vfp_ctx *ctx, struct vfp_entry *ent)
* Ignore partial responses to range requests (as Varnish does for
* gzip and gunzip).
*/
if (http_GetStatus(ctx->resp) == 206)
return (VFP_NULL);
if (http_GetStatus(vc->resp) == 206)
return (VFP_NULL);
if (priv->stats != NULL)
priv->stats->ops++;
if (settings->which == ENC) {
if (http_GetHdr(ctx->resp, H_Content_Encoding, NULL))
if (http_GetHdr(vc->resp, H_Content_Encoding, NULL))
return (VFP_NULL);
vbr = newVBR(ENC);
}
else {
if (!http_HdrIs(ctx->resp, H_Content_Encoding, "br"))
if (!http_HdrIs(vc->resp, H_Content_Encoding, "br"))
return (VFP_NULL);
vbr = newVBR(DEC);
}
......@@ -346,14 +347,14 @@ vfp_br_init(struct vfp_ctx *ctx, struct vfp_entry *ent)
setInputBuf(vbr, vbr->buf, 0);
AZ(vbr->buflen);
http_Unset(ctx->resp, H_Content_Encoding);
http_Unset(ctx->resp, H_Content_Length);
RFC2616_Weaken_Etag(ctx->resp);
ctx->obj_flags |= OF_CHGCE;
http_Unset(vc->resp, H_Content_Encoding);
http_Unset(vc->resp, H_Content_Length);
RFC2616_Weaken_Etag(vc->resp);
vc->obj_flags |= OF_CHGCE;
if (settings->which == ENC) {
http_SetHeader(ctx->resp, "Content-Encoding: br");
RFC2616_Vary_AE(ctx->resp);
http_SetHeader(vc->resp, "Content-Encoding: br");
RFC2616_Vary_AE(vc->resp);
}
return (VFP_OK);
......@@ -569,6 +570,7 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
struct custom_vfp_head *vfph;
struct custom_vfp_entry *vfpe;
struct vfp_priv *vfp_priv;
const char *err;
ASSERT_CLI();
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
......@@ -578,8 +580,12 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
switch(e) {
case VCL_EVENT_LOAD:
VRT_AddVFP(ctx, &vfp_br);
VRT_AddVFP(ctx, &vfp_unbr);
err = VRT_AddFilter(ctx, &vfp_br, NULL);
if (err != NULL)
return (1);
err = VRT_AddFilter(ctx, &vfp_unbr, NULL);
if (err != NULL)
return (1);
CAST_OBJ_NOTNULL(vfp_priv, TRUST_ME(vfp_br.priv1),
VFP_PRIV_MAGIC);
if (vfp_priv->stats == NULL)
......@@ -594,8 +600,8 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
"unbr");
return (0);
case VCL_EVENT_DISCARD:
VRT_RemoveVFP(ctx, &vfp_br);
VRT_RemoveVFP(ctx, &vfp_unbr);
VRT_RemoveFilter(ctx, &vfp_br, NULL);
VRT_RemoveFilter(ctx, &vfp_unbr, NULL);
while (!VSLIST_EMPTY(vfph)) {
vfpe = VSLIST_FIRST(vfph);
CHECK_OBJ_NOTNULL(vfpe, CUSTOM_VFP_MAGIC);
......
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