Commit d2f603c5 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

esi: Skip the response body for onerror="continue"

That is to say, when we can actually do that.
parent c5b7a014
......@@ -881,8 +881,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
status = req->resp->status % 1000;
if (ecx->abrt && status != 200 && status != 204) {
ved_close(req, boc, 1);
if (FEATURE(FEATURE_ESI_INCLUDE_ONERROR) &&
status != 200 && status != 204) {
ved_close(req, boc, ecx->abrt);
return;
}
......
......@@ -8,7 +8,7 @@ server s1 {
rxreq
expect req.url == "/fail"
txresp -hdr "content-length: 100" -nolen
txresp -hdr "content-length: 100"
delay 0.1
} -start
......@@ -17,6 +17,7 @@ varnish v1 -cliok "param.set feature +esi_include_onerror"
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.do_esi = beresp.http.surrogate-control ~ "ESI/1.0";
set beresp.do_stream = beresp.http.stream != "false";
unset beresp.http.surrogate-control;
}
} -start
......@@ -38,7 +39,7 @@ server s1 {
rxreq
expect req.url == "/fail"
txresp -hdr "content-length: 100" -nolen
txresp -hdr "content-length: 100"
delay 0.1
} -start
......@@ -48,3 +49,24 @@ client c1 {
rxresp
expect resp.body == "before after"
} -run
server s1 -wait
server s1 {
rxreq
expect req.url == "/continue-no-stream"
txresp -hdr {surrogate-control: content="ESI/1.0"} \
-body {before <esi:include src="/err" onerror="continue"/> after}
rxreq
expect req.url == "/err"
txresp -hdr "content-encoding chunked" -hdr "stream: false"
chunked "incomplete"
} -start
client c1 {
fatal
txreq -url "/continue-no-stream"
rxresp
expect resp.body == "before after"
} -run
......@@ -93,7 +93,7 @@ client c1 {
fatal
txreq -url "/continue"
rxresp
expect resp.body == "before FOOBAR after"
expect resp.body == "before after"
} -run
varnish v1 -cliok "param.set max_esi_depth 0"
......
......@@ -128,7 +128,10 @@ continue in case of failures, by setting::
param.set feature +esi_include_onerror
Once this feature flag is enabled, a delivery failure can only continue
if an ``onerror`` attribute said so.
if an ``onerror`` attribute said so. The ESI specification states that
in that case the failing fragment is not delivered, which is honored based
on the status code, or based on the response body only when streaming is
disabled (see ``beresp.do_stream``).
Can an ESI fragment also use ESI-includes ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
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