Commit 52b72752 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Now that we have more confidence in the gzip-patchworking-code be less

draconian about error handling and debugging.

Properly handle two src= attributes in an esi:include tag (ignore
the entire tag, log the error)

Deal with clients which close the connection half-way through an
ESI delivery.
parent ad3f1341
......@@ -693,6 +693,7 @@ int VGZ_WrwGunzip(struct sess *, struct vgz *, void *ibuf, ssize_t ibufl,
char *obuf, ssize_t obufl, ssize_t *obufp);
/* Return values */
#define VGZ_SOCKET -2
#define VGZ_ERROR -1
#define VGZ_OK 0
#define VGZ_END 1
......
......@@ -59,11 +59,6 @@ ved_include(struct sess *sp, const char *src, const char *host)
return;
sp->esi_level++;
if (WRW_Flush(w)) {
vca_close_session(sp, "remote closed");
return;
}
(void)WRW_FlushRelease(w);
obj = sp->obj;
......@@ -335,6 +330,12 @@ ESI_Deliver(struct sess *sp)
i = VGZ_WrwGunzip(sp, vgz,
st->ptr + off, l2,
obuf, sizeof obuf, &obufl);
if (i == VGZ_SOCKET) {
vca_close_session(sp,
"remote closed");
p = e;
break;
}
assert (i == VGZ_OK || i == VGZ_END);
} else {
/*
......@@ -382,6 +383,11 @@ ESI_Deliver(struct sess *sp)
WRW_Write(sp->wrk, obuf, obufl);
obufl = 0;
}
if (WRW_Flush(sp->wrk)) {
vca_close_session(sp, "remote closed");
p = e;
break;
}
Debug("INCL [%s][%s] BEGIN\n", q, p);
ved_include(sp, (const char*)q, (const char*)p);
Debug("INCL [%s][%s] END\n", q, p);
......
......@@ -188,7 +188,6 @@ vep_error(const struct vep_state *vep, const char *p)
VSC_main->esi_errors++;
l = (intmax_t)(vep->ver_p - vep->hack_p);
printf("ERROR at %jd %s\n", l , p);
WSP(vep->sp, SLT_ESI_xmlerror, "ERR at %jd %s", l, p);
}
......@@ -450,6 +449,17 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
if (what == DO_ATTR) {
Debug("ATTR (%s) (%s)\n", vep->match_hit->match,
vsb_data(vep->attr_vsb));
if (vep->include_src != NULL) {
vep_error(vep,
"ESI 1.0 <esi:include> "
"has multiple src= attributes");
vep->state = VEP_TAGERROR;
vsb_delete(vep->attr_vsb);
vsb_delete(vep->include_src);
vep->attr_vsb = NULL;
vep->include_src = NULL;
return;
}
XXXAZ(vep->include_src); /* multiple src= */
vep->include_src = vep->attr_vsb;
return;
......@@ -872,13 +882,13 @@ VEP_parse(const struct sess *sp, const char *p, size_t l)
} else if (p < e) {
vep->attr_delim = 0;
p++;
vep->state = VEP_INTAG;
if (vep->attr_vsb != NULL) {
vsb_finish(vep->attr_vsb);
AN(vep->dostuff);
vep->dostuff(vep, DO_ATTR);
vep->attr_vsb = NULL;
}
vep->state = VEP_INTAG;
}
/******************************************************
......
......@@ -383,7 +383,7 @@ VGZ_WrwGunzip(struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl,
if (obufl == *obufp || i == VGZ_STUCK) {
WRW_Write(sp->wrk, obuf, *obufp);
if (WRW_Flush(sp->wrk))
return (-1);
return (VGZ_SOCKET);
*obufp = 0;
VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp);
}
......
# $Id$
test "Ticket #894"
server s1 {
rxreq
txresp -body {<XXX><esi:include src="a" src="b"/><YYY>}
} -start
varnish v1 -vcl+backend {
sub vcl_fetch {
set beresp.do_esi = true;
}
} -start
client c1 {
txreq
rxresp
expect resp.bodylen == 10
} -run
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