varnishtest "#1737 - ESI sublevel session close"

barrier b1 cond 2

# Build a esi request tree that fails on flush before include at two different
# levels. Synchronize a client close after the response headers have been
# received by the client. This produces write erros for the body parts in all
# fragments.
server s1 {
	rxreq
	txresp -body {<esi:include src="/bar"/><esi:include src="/bar"/>}
	barrier b1 sync

	rxreq
	delay 1
	txresp -body {<esi:include src="/baz"/>22<esi:include src="/baz"/>}

	rxreq
	txresp -body {1}

	rxreq
	expect req.url == "/check"
	rxresp
} -start

varnish v1 -arg "-p feature=+esi_disable_xml_check" -vcl+backend {
	sub vcl_backend_response {
		set beresp.do_esi = true;
	}
} -start

# Send request, read response headers then close connection
client c1 {
	txreq
	rxresp -no_obj
	barrier b1 sync
} -run

delay 3

# Check that Varnish is alive
client c1 {
	txreq
	rxresp
} -run
