vtest "ESI binary detector"

server s1 {
	rxreq
	txresp -body {
		Before include
		<esi:remove>
			bar
		</esi:remove>
	}
	rxreq
	txresp -body {
		Before include
		<esi:remove>
			bar
		</esi:remove>
	}
} -start

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

logexpect l1 -v v1 -g raw {
	expect * 1002 ESI_xmlerror esi_disable_xml_check
} -start

client c1 {
	txreq
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 57
} -run

logexpect l1 -wait
vinyl v1 -expect MAIN.s_resp_bodybytes == 57

vinyl v1  -cli "param.set feature +esi_disable_xml_check"

client c1 {
	txreq -url /bar
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 22
	expect resp.http.transfer-encoding == "chunked"
} -run
vinyl v1 -expect esi_errors == 0
vinyl v1 -expect MAIN.s_resp_bodybytes == 79
