varnishtest "#1029"

server s1 {
	rxreq
	expect req.url == "/bar"
	txresp -gzipbody {[bar]}

	rxreq
	expect req.url == "/foo"
	txresp -body {<h1>FOO<esi:include src="/bar"/>BARF</h1>}

} -start

varnish v1 -vcl+backend {
	sub vcl_backend_response {
		if (bereq.url == "/foo") {
			set beresp.do_esi = true;
			set beresp.ttl = 0s;
		} else {
			set beresp.ttl = 10m;
		}
	}
} -start

client c1 {
	txreq -url "/bar" -hdr "Accept-Encoding: gzip,foo"
	rxresp
	gunzip
	expect resp.bodylen == 5

	txreq -url "/foo" -hdr "Accept-Encoding: gzip,foo"
	rxresp
	expect resp.bodylen == 21
} -run
