Commit 3247c51d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make pretend_gzip a VDP

parent 16322792
......@@ -1119,6 +1119,7 @@ void VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id);
void ESI_Deliver(struct req *);
void ESI_DeliverChild(struct req *);
vdp_bytes VED_pretend_gzip;
/* cache_vrt_vmod.c */
void VMOD_Init(void);
......
......@@ -205,12 +205,18 @@ ved_decode_len(uint8_t **pp)
* the stream with a bit more overhead.
*/
static int
ved_pretend_gzip(struct req *req, const uint8_t *p, ssize_t l)
int __match_proto__(vdp_bytes)
VED_pretend_gzip(struct req *req, enum vdp_action act, const void *pv,
ssize_t l)
{
uint8_t buf1[5], buf2[5];
const uint8_t *p;
uint16_t lx;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
(void)act;
p = pv;
lx = 65535;
buf1[0] = 0;
vle16enc(buf1 + 1, lx);
......@@ -355,7 +361,8 @@ ESI_Deliver(struct req *req)
* A gzip'ed ESI response, but the VEC
* was not gzip'ed.
*/
(void)ved_pretend_gzip(req, pp, l2);
(void)VED_pretend_gzip(req, VDP_NULL,
pp, l2);
} else if (isgzip) {
/*
* A gzip'ed VEC, but ungzip'ed ESI
......@@ -482,16 +489,8 @@ ESI_DeliverChild(struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
if (!ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED)) {
oi = ObjIterBegin(req->wrk, req->objcore);
do {
ois = ObjIter(req->objcore, oi, &sp, &sl);
if (sl > 0 && ved_pretend_gzip(req, sp, sl))
break;
} while (ois == OIS_DATA || ois == OIS_STREAM);
ObjIterEnd(req->objcore, &oi);
return;
}
AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
/*
* This is the interesting case: Deliver all the deflate
* blocks, stripping the "LAST" bit of the last one and
......
......@@ -340,6 +340,11 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
/* This was a HEAD or conditional request */
} else if (req->res_mode & RES_ESI) {
ESI_Deliver(req);
} else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp &&
!ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED)) {
VDP_push(req, VED_pretend_gzip);
ois = v1d_WriteDirObj(req);
VDP_pop(req, VED_pretend_gzip);
} else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) {
if (bo != NULL)
VBO_waitstate(bo, BOS_FINISHED);
......
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