Commit e0e89a69 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the header-munging to the VFP's that require it.

parent 8fb7bf02
......@@ -157,10 +157,15 @@ vfp_esi_gzip_init(struct busyobj *bo, struct vfp_entry *vfe)
vef->ibuf = calloc(1L, vef->ibuf_sz);
if (vef->ibuf == NULL)
return (vfp_esi_end(bo, vef, VFP_ERROR));
XXXAN(vef->ibuf);
vef->ibuf_i = vef->ibuf;
vef->ibuf_o = vef->ibuf;
vfe->priv1 = vef;
RFC2616_Weaken_Etag(bo->beresp);
http_Unset(bo->beresp, H_Content_Length);
http_Unset(bo->beresp, H_Content_Encoding);
http_SetHeader(bo->beresp, "Content-Encoding: gzip");
return (VFP_OK);
}
......
......@@ -446,28 +446,17 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
/* But we can't do both at the same time */
assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
/* Fix Content-Encoding, as appropriate */
if (bo->do_gzip)
http_SetHeader(bo->beresp, "Content-Encoding: gzip");
else if (bo->do_gunzip)
http_Unset(bo->beresp, H_Content_Encoding);
if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) {
RFC2616_Weaken_Etag(bo->beresp);
if (bo->do_gunzip || (bo->is_gzip && bo->do_esi))
VFP_Push(bo, &vfp_gunzip, 0, 1);
}
if (bo->do_esi && bo->do_gzip) {
VFP_Push(bo, &vfp_esi_gzip, 0, 1);
RFC2616_Weaken_Etag(bo->beresp);
} else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) {
VFP_Push(bo, &vfp_esi_gzip, 0, 1);
RFC2616_Weaken_Etag(bo->beresp);
} else if (bo->do_esi) {
VFP_Push(bo, &vfp_esi, 0, 1);
} else if (bo->do_gzip) {
VFP_Push(bo, &vfp_gzip, 0, 1);
RFC2616_Weaken_Etag(bo->beresp);
} else if (bo->is_gzip && !bo->do_gunzip) {
VFP_Push(bo, &vfp_testgunzip, 0, 1);
}
......
......@@ -458,13 +458,20 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe)
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
if (bo->content_length == 0)
if (bo->content_length == 0) {
http_Unset(bo->beresp, H_Content_Encoding);
return (VFP_NULL);
}
if (vfe->vfp->priv2 == VFP_GZIP)
if (vfe->vfp->priv2 == VFP_GZIP) {
if (http_GetHdr(bo->beresp, H_Content_Encoding, NULL))
return (VFP_NULL);
vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1);
else
} else {
if (!http_HdrIs(bo->beresp, H_Content_Encoding, "gzip"))
return (VFP_NULL);
vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1);
}
if (vg == NULL)
return (VFP_ERROR);
vfe->priv1 = vg;
......@@ -472,6 +479,16 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe)
return (VFP_ERROR);
VGZ_Ibuf(vg, vg->m_buf, 0);
AZ(vg->m_len);
if (vfe->vfp->priv2 == VFP_GUNZIP || vfe->vfp->priv2 == VFP_GZIP) {
http_Unset(bo->beresp, H_Content_Encoding);
http_Unset(bo->beresp, H_Content_Length);
RFC2616_Weaken_Etag(bo->beresp);
}
if (vfe->vfp->priv2 == VFP_GZIP)
http_SetHeader(bo->beresp, "Content-Encoding: gzip");
return (VFP_OK);
}
......
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