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

Call ESI_Deliver() as a VDP.

Only allow VDP_ungzip to set a length if it is the top VDP.
parent d8d9cd02
......@@ -1107,7 +1107,6 @@ char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
void VRTPRIV_init(struct vrt_privs *privs);
void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id);
void ESI_Deliver(struct req *);
void ESI_DeliverChild(struct req *, struct busyobj *);
/* cache_vrt_vmod.c */
......
......@@ -113,11 +113,6 @@ VDP_DeliverObj(struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (req->res_mode & RES_ESI) {
ESI_Deliver(req);
return (OIS_DONE);
}
oi = ObjIterBegin(req->wrk, req->objcore);
XXXAN(oi);
AZ(req->synth_body);
......
......@@ -286,7 +286,7 @@ struct ecx {
int isgzip;
};
static int __match_proto__(vdp_bytes)
int __match_proto__(vdp_bytes)
VDP_ESI(struct req *req, enum vdp_action act, void **priv,
const void *ptr, ssize_t len)
{
......@@ -459,33 +459,6 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv,
}
}
/*---------------------------------------------------------------------
*/
void
ESI_Deliver(struct req *req)
{
enum objiter_status ois;
void *sp = NULL;
ssize_t sl;
void *oi;
void *vp = NULL;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
(void)VDP_ESI(req, VDP_INIT, &vp, NULL, 0);
oi = ObjIterBegin(req->wrk, req->objcore);
do {
ois = ObjIter(req->objcore, oi, &sp, &sl);
assert(ois != OIS_ERROR);
(void)VDP_ESI(req, VDP_FLUSH, &vp, sp, sl);
} while (ois != OIS_DONE);
(void)VDP_ESI(req, VDP_FINI, &vp, NULL, 0);
ObjIterEnd(req->objcore, &oi);
}
/*---------------------------------------------------------------------
* Include an object in a gzip'ed ESI object delivery
*/
......@@ -693,6 +666,8 @@ ESI_DeliverChild(struct req *req, struct busyobj *bo)
ved_stripgzip(req);
(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
} else {
if (req->res_mode & RES_ESI)
VDP_push(req, VDP_ESI, NULL, 0);
if (req->gzip_resp && !i)
VDP_push(req, ved_pretend_gzip, NULL, 0);
else if (!req->gzip_resp && i)
......
......@@ -111,3 +111,4 @@ void VDP_close(struct req *req);
enum objiter_status VDP_DeliverObj(struct req *req);
vdp_bytes VDP_gunzip;
vdp_bytes VDP_ESI;
......@@ -296,8 +296,12 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
p = ObjGetattr(req->wrk, req->objcore, OA_GZIPBITS, &dl);
if (p != NULL && dl == 32) {
u = vbe64dec(p + 24);
/* XXX: Zero is suspect: OA_GZIPBITS wasn't set */
if (u != 0)
/*
* If the size is non-zero, and we are the top
* VDP, we know what size the output will be.
*/
if (u != 0 &&
VTAILQ_FIRST(&req->vdp)->func == VDP_gunzip)
req->resp_len = u;
else
req->resp_len = -1;
......
......@@ -90,6 +90,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
if (req->res_mode & RES_ESI) {
RFC2616_Weaken_Etag(req->resp);
VDP_push(req, VDP_ESI, NULL, 0);
} else if (http_IsStatus(req->resp, 304)) {
http_Unset(req->resp, H_Content_Length);
req->wantbody = 0;
......@@ -105,13 +106,13 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
* XXX: with multiple writes because of the gunzip buffer
*/
req->res_mode |= RES_GUNZIP;
VDP_push(req, VDP_gunzip, NULL, 0);
VDP_push(req, VDP_gunzip, NULL, 1);
}
if (req->res_mode & RES_ESI) {
/* Gunzip could have added back a C-L */
http_Unset(req->resp, H_Content_Length);
req->resp_len = -1;
assert(req->resp_len < 0);
}
/*
......
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