varnishtest "Test case for #1092 - esi:remove and comments"

server s1 {
	rxreq
	txresp -body {
		<html>
		Keep-1
		<!--esX Keep-22 -->
		<!--esi Keep-333 -->
		<esi:remove>
		Remove-1
		<!-- Remove-22 -->
		<!--esi Remove-333 -->
		Remove-4444
		</esi:remove>
		Keep-4444
		</html>
	}
} -start

varnish v1 -vcl+backend {
	sub vcl_backend_response {
		set beresp.do_esi = true;
	}
} -start

logexpect l1 -v v1 -g raw {
	expect * * Fetch_Body
	expect 0 * ESI_xmlerror {^ERR after 66 ESI 1.0 Nested <!--esi element in <esi:remove>$}
	expect 0 = BackendReuse
} -start

client c1 {
	txreq
	rxresp
	expect resp.bodylen == 80
}

client c1 -run
varnish v1 -expect esi_errors == 1
logexpect l1 -wait
