Avoid a brain twister: For onerror=continue, use the same semantics as varnish-cache

Related prep-work for !6
parent e2352c14
......@@ -50,7 +50,7 @@ struct pecx {
ssize_t l;
int state;
int abrt;
int incl_cont;
};
struct pesi {
......
varnishtest "ESI onerror"
server s1 {
rxreq
expect req.url == "/abort"
txresp -hdr {surrogate-control: content="ESI/1.0"} \
-body {before <esi:include src="/fail" onerror="abort"/> after}
} -start
varnish v1 -cliok "param.set feature +esi_disable_xml_check"
varnish v1 -cliok "param.set feature +esi_include_onerror"
varnish v1 -vcl+backend {
import ${vmod_pesi};
sub vcl_backend_fetch {
if (bereq.url == "/fail") {
return (error(604));
}
}
sub vcl_backend_response {
set beresp.do_esi = beresp.http.surrogate-control ~ "ESI/1.0";
unset beresp.http.surrogate-control;
}
sub vcl_backend_error {
if (beresp.status == 604) {
set beresp.body = "FOOBAR";
return(deliver);
}
}
sub vcl_deliver {
pesi.activate();
}
} -start
client c1 {
txreq -url "/abort"
non_fatal
rxresphdrs
expect resp.status == 200
rxchunk
expect_close
expect resp.body == "before "
} -run
varnish v1 -vsl_catchup
server s1 -wait
server s1 {
rxreq
expect req.url == "/continue"
txresp -hdr {surrogate-control: content="ESI/1.0"} \
-body {before <esi:include src="/fail" onerror="continue"/> after}
} -start
client c1 {
fatal
txreq -url "/continue"
rxresp
expect resp.body == "before FOOBAR after"
} -run
......@@ -863,7 +863,7 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
struct nexus_gzip *parent_gzip = NULL;
struct bytes_tree *tree;
struct node *node, *child = NULL;
int abrt, retval = 0, parallel;
int incl_cont, retval = 0, parallel;
CHECK_OBJ_NOTNULL(vdx, VDP_CTX_MAGIC);
......@@ -908,7 +908,7 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
pp = ptr;
while (1) {
abrt = 0;
incl_cont = 0;
switch (pecx->state) {
case 0:
pecx->p = ObjGetAttr(req->wrk, req->objcore,
......@@ -982,10 +982,11 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
Debug("SKIP1(%d)\n", (int)pecx->l);
pecx->state = 4;
break;
case VEC_IA:
abrt = FEATURE(FEATURE_ESI_INCLUDE_ONERROR);
/* FALLTHROUGH */
case VEC_IC:
incl_cont =
FEATURE(FEATURE_ESI_INCLUDE_ONERROR);
/* FALLTHROUGH */
case VEC_IA:
pecx->p++;
q = (void*)strchr((const char*)pecx->p, '\0');
AN(q);
......@@ -1003,9 +1004,9 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
node_insert(tree, node, child);
pesi->pecx->abrt = abrt;
pesi->pecx->incl_cont = incl_cont;
VSLdbgv(vdx, "vped_vdp: call vped_include "
"abrt=%d", abrt);
"incl_cont=%d", incl_cont);
parallel =
vped_include(req, (const char*)q,
(const char*)pecx->p,
......@@ -1244,8 +1245,8 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
parent = node->parent;
CHECK_OBJ_NOTNULL(parent, NODE_MAGIC);
VSLdbgv(req, "vped_deliver: req=%p boc=%p wantbody=%d abrt=%d",
req, boc, wantbody, pesi->pecx->abrt);
VSLdbgv(req, "vped_deliver: req=%p boc=%p wantbody=%d incl_cont=%d",
req, boc, wantbody, pesi->pecx->incl_cont);
assert(parent->type == T_NEXUS);
if (wantbody == 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