vtest "#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 errors 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

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

vinyl v1 -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 Vinyl is alive
client c1 {
	txreq
	rxresp
} -run
