Commit 322bcca6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Make the individual VFP->init()'s responsible for the objflags.

parent ad9aab0b
......@@ -156,6 +156,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
ALLOC_OBJ(vef, VEF_MAGIC);
if (vef == NULL)
return (VFP_ERROR);
vc->obj_flags |= OF_GZIPED | OF_CHGGZIP | OF_ESIPROC;
vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E");
vef->vep = VEP_Init(vc, vc->req, vfp_vep_callback, vef);
vef->ibuf_sz = cache_param->gzip_buffer;
......@@ -229,6 +230,7 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
ALLOC_OBJ(vef, VEF_MAGIC);
if (vef == NULL)
return (VFP_ERROR);
vc->obj_flags |= OF_ESIPROC;
vef->vep = VEP_Init(vc, vc->req, NULL, NULL);
vfe->priv1 = vef;
return (VFP_OK);
......
......@@ -503,6 +503,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo)
static int
vbf_figure_out_vfp(struct busyobj *bo)
{
int is_gzip, is_gunzip;
/*
* The VCL variables beresp.do_g[un]zip tells us how we want the
......@@ -543,26 +544,26 @@ vbf_figure_out_vfp(struct busyobj *bo)
if (!cache_param->http_gzip_support)
bo->do_gzip = bo->do_gunzip = 0;
bo->is_gzip = http_HdrIs(bo->beresp, H_Content_Encoding, "gzip");
bo->is_gunzip = !http_GetHdr(bo->beresp, H_Content_Encoding, NULL);
assert(bo->is_gzip == 0 || bo->is_gunzip == 0);
is_gzip = http_HdrIs(bo->beresp, H_Content_Encoding, "gzip");
is_gunzip = !http_GetHdr(bo->beresp, H_Content_Encoding, NULL);
assert(is_gzip == 0 || is_gunzip == 0);
/* We won't gunzip unless it is gzip'ed */
if (bo->do_gunzip && !bo->is_gzip)
if (bo->do_gunzip && !is_gzip)
bo->do_gunzip = 0;
/* We wont gzip unless if it already is gzip'ed */
if (bo->do_gzip && !bo->is_gunzip)
if (bo->do_gzip && !is_gunzip)
bo->do_gzip = 0;
/* But we can't do both at the same time */
assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
if (bo->do_gunzip || (bo->is_gzip && bo->do_esi))
if (bo->do_gunzip || (is_gzip && bo->do_esi))
if (VFP_Push(bo->vfc, &VFP_gunzip) == NULL)
return (-1);
if (bo->do_esi && (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)))
if (bo->do_esi && (bo->do_gzip || (is_gzip && !bo->do_gunzip)))
return (VFP_Push(bo->vfc, &VFP_esi_gzip) == NULL ? -1 : 0);
if (bo->do_esi)
......@@ -571,7 +572,7 @@ vbf_figure_out_vfp(struct busyobj *bo)
if (bo->do_gzip)
return (VFP_Push(bo->vfc, &VFP_gzip) == NULL ? -1 : 0);
if (bo->is_gzip && !bo->do_gunzip)
if (is_gzip && !bo->do_gunzip)
return (VFP_Push(bo->vfc, &VFP_testgunzip) == NULL ? -1 : 0);
return (0);
......@@ -614,14 +615,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
return (F_STP_ERROR);
}
if (bo->do_esi)
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_ESIPROC, 1);
if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip))
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_GZIPED, 1);
if (bo->do_gzip || bo->do_gunzip)
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_CHGGZIP, 1);
#define OBJ_FLAG(U, l, v) \
if (bo->vfc->obj_flags & OF_##U) \
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_##U, 1);
#include "tbl/obj_attr.h"
if (!(bo->fetch_objcore->flags & OC_F_PASS) &&
http_IsStatus(bo->beresp, 200) && (
......
......@@ -82,6 +82,7 @@ struct vfp_ctx {
struct vfp_entry_s vfp;
struct vfp_entry *vfp_nxt;
unsigned obj_flags;
};
enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp);
......
......@@ -446,13 +446,18 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
if (http_GetHdr(vc->resp, H_Content_Encoding, NULL))
return (VFP_NULL);
vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1);
vc->obj_flags |= OF_GZIPED | OF_CHGGZIP;
} else {
if (!http_HdrIs(vc->resp, H_Content_Encoding, "gzip"))
return (VFP_NULL);
if (vfe->vfp == &VFP_gunzip)
if (vfe->vfp == &VFP_gunzip) {
vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1);
else
vc->obj_flags &= ~OF_GZIPED;
vc->obj_flags |= OF_CHGGZIP;
} else {
vg = VGZ_NewTestGunzip(vc->wrk->vsl, vfe->vfp->priv1);
vc->obj_flags |= OF_GZIPED;
}
}
if (vg == NULL)
return (VFP_ERROR);
......
......@@ -36,8 +36,6 @@ BO_FLAG(do_gunzip, 1, 1, "")
BO_FLAG(do_stream, 1, 1, "")
BO_FLAG(do_pass, 0, 0, "")
BO_FLAG(uncacheable, 0, 0, "")
BO_FLAG(is_gzip, 0, 0, "")
BO_FLAG(is_gunzip, 0, 0, "")
BO_FLAG(was_304, 1, 0, "")
BO_FLAG(is_bgfetch, 0, 0, "")
#undef BO_FLAG
......
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