vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vef_priv *vef; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->esi_req, HTTP_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E"); vef->vep = VEP_Init(vc, vc->esi_req, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) return (vfp_esi_end(vc, vef, VFP_ERROR)); vef->ibuf_i = vef->ibuf; vef->ibuf_o = vef->ibuf; vfe->priv1 = vef; RFC2616_Weaken_Etag(vc->http); http_Unset(vc->http, H_Content_Length); http_Unset(vc->http, H_Content_Encoding); http_SetHeader(vc->http, "Content-Encoding: gzip"); RFC2616_Vary_AE(vc->http); return (VFP_OK); }
vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vef_priv *vef; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->req, HTTP_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (http_GetStatus(vc->resp) == 206) { VSLb(vc->wrk->vsl, SLT_VCL_Error, "Attempted ESI on partial (206) response"); return (VFP_ERROR); } 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; vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) return (vfp_esi_end(vc, vef, VFP_ERROR)); vef->ibuf_i = vef->ibuf; vef->ibuf_o = vef->ibuf; vfe->priv1 = vef; RFC2616_Weaken_Etag(vc->resp); http_Unset(vc->resp, H_Content_Length); http_Unset(vc->resp, H_Content_Encoding); http_SetHeader(vc->resp, "Content-Encoding: gzip"); RFC2616_Vary_AE(vc->resp); return (VFP_OK); }
vfp_gzip_begin(struct busyobj *bo, size_t estimate) { (void)estimate; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(bo->vgz_rx); bo->vgz_rx = VGZ_NewGzip(bo->vsl, "G F -"); XXXAZ(vgz_getmbuf(bo->vgz_rx)); }
vfp_esi_begin(struct busyobj *bo, size_t estimate) { struct vef_priv *vef; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); (void)estimate; ALLOC_OBJ(vef, VEF_MAGIC); XXXAN(vef); AZ(bo->vef_priv); bo->vef_priv = vef; AZ(bo->vgz_rx); if (bo->is_gzip && bo->do_gunzip) { bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F E"); VEP_Init(bo, NULL); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gzip) { bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F E"); vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf2_sz = cache_param->gzip_buffer; } else { VEP_Init(bo, NULL); } if (vef->ibuf_sz > 0) { vef->ibuf = calloc(1L, vef->ibuf_sz); XXXAN(vef->ibuf); vef->ibuf_i = vef->ibuf; vef->ibuf_o = vef->ibuf; } if (vef->ibuf2_sz > 0) { vef->ibuf2 = calloc(1L, vef->ibuf2_sz); XXXAN(vef->ibuf2); } AN(bo->vep); }
vfp_esi_begin(struct sess *sp, size_t estimate) { struct vef_priv *vef; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); /* XXX: snapshot WS's ? We'll need the space */ AZ(sp->wrk->vgz_rx); if (sp->wrk->is_gzip && sp->wrk->do_gunzip) { sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F E"); VEP_Init(sp, NULL); } else if (sp->wrk->is_gunzip && sp->wrk->do_gzip) { ALLOC_OBJ(vef, VEF_MAGIC); AN(vef); //vef = (void*)WS_Alloc(sp->ws, sizeof *vef); //memset(vef, 0, sizeof *vef); //vef->magic = VEF_MAGIC; vef->vgz = VGZ_NewGzip(sp, "G F E"); AZ(sp->wrk->vef_priv); sp->wrk->vef_priv = vef; VEP_Init(sp, vfp_vep_callback); } else if (sp->wrk->is_gzip) { sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F E"); ALLOC_OBJ(vef, VEF_MAGIC); AN(vef); //vef = (void*)WS_Alloc(sp->ws, sizeof *vef); //memset(vef, 0, sizeof *vef); //vef->magic = VEF_MAGIC; vef->vgz = VGZ_NewGzip(sp, "G F E"); AZ(sp->wrk->vef_priv); sp->wrk->vef_priv = vef; VEP_Init(sp, vfp_vep_callback); } else { AZ(sp->wrk->vef_priv); VEP_Init(sp, NULL); } (void)estimate; AN(sp->wrk->vep); }
vfp_esi_begin(struct worker *wrk, size_t estimate) { struct busyobj *bo; struct vef_priv *vef; (void)estimate; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(bo->vgz_rx); if (bo->is_gzip && bo->do_gunzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); VEP_Init(wrk, NULL); } else if (bo->is_gunzip && bo->do_gzip) { ALLOC_OBJ(vef, VEF_MAGIC); AN(vef); vef->vgz = VGZ_NewGzip(wrk, "G F E"); AZ(bo->vef_priv); bo->vef_priv = vef; VEP_Init(wrk, vfp_vep_callback); } else if (bo->is_gzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); ALLOC_OBJ(vef, VEF_MAGIC); AN(vef); vef->vgz = VGZ_NewGzip(wrk, "G F E"); AZ(bo->vef_priv); bo->vef_priv = vef; VEP_Init(wrk, vfp_vep_callback); } else { AZ(bo->vef_priv); VEP_Init(wrk, NULL); } AN(bo->vep); }
vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vgz *vg; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (http_HdrIs(vc->http, H_Content_Length, "0")) { http_Unset(vc->http, H_Content_Encoding); return (VFP_NULL); } if (vfe->vfp->priv2 == VFP_GZIP) { if (http_GetHdr(vc->http, H_Content_Encoding, NULL)) return (VFP_NULL); vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1); } else { if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip")) return (VFP_NULL); vg = VGZ_NewUngzip(vc->wrk->vsl, vfe->vfp->priv1); } if (vg == NULL) return (VFP_ERROR); vfe->priv1 = vg; if (vgz_getmbuf(vg)) 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(vc->http, H_Content_Encoding); http_Unset(vc->http, H_Content_Length); RFC2616_Weaken_Etag(vc->http); } if (vfe->vfp->priv2 == VFP_GZIP) http_SetHeader(vc->http, "Content-Encoding: gzip"); if (vfe->vfp->priv2 == VFP_GZIP || vfe->vfp->priv2 == VFP_TESTGUNZIP) RFC2616_Vary_AE(vc->http); return (VFP_OK); }
vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) { struct vgz *vg; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (vfe->vfp->priv2) vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1); else vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1); if (vg == NULL) return (VFP_ERROR); if (vgz_getmbuf(vg)) return (VFP_ERROR); vfe->priv1 = vg; VGZ_Ibuf(vg, vg->m_buf, 0); AZ(vg->m_len); return (VFP_OK); }
vfp_esi_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) { struct vef_priv *vef; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); vef->vep = VEP_Init(bo, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; 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; return (VFP_OK); }