varnishtest "ESI request can't be turned off midstream"

server s1 {
	rxreq
	txresp -body {
		<html>
		Before include
		<esi:include src="/body"/>
		<esi:include src="/body3"/>
		After include
	}
	rxreq
	expect req.url == "/body"
	txresp -body {
	       <esi:include src="/body2"/>
	}
	rxreq
	expect req.url == "/body2"
	txresp -body {
	       included
	}
	rxreq
	expect req.url == "/body3"
	txresp -body {
	       included body3
	}
} -start

# give enough stack to 32bit systems
varnish v1 -cliok "param.set thread_pool_stack 80k"
varnish v1 -cliok "param.set feature +esi_disable_xml_check"

varnish v1 -syntax 4.0 -vcl+backend {
	sub vcl_backend_response {
		set beresp.do_esi = true;
	}
	sub vcl_deliver {
		set req.esi = true;
		if (req.url == "/body") {
			set req.esi = false;
		}
	}
} -start

client c1 {
	txreq
	rxresp
	expect resp.bodylen == 105
	expect resp.status == 200
}

client c1 -run
varnish v1 -expect esi_errors == 0
varnish v1 -expect MAIN.s_resp_bodybytes == 105
