vinyltest "fun esi includes and ranges"

# this does not work yet because the ESI VDP pushes data directly
# to the next level up, which in turn is required to get the
# anything-in-gzip case right

server s1 {
	rxreq
	expect req.url == "/1"
	txresp -body {<html><esi:include src="/bar"/></html>}

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

	rxreq
	expect req.url == /foo
	txresp -body "ABCD"

	rxreq
	expect req.url == "/2"
	txresp -gzipbody {<html><esi:include src="/bar"/></html>}

} -start

vinyl v1 -vcl+backend {
	sub vcl_recv {
		if (req.url == "/bar") {
			set req.http.Range = "bytes=7-8";
		}
	}
	sub vcl_backend_response {
		set beresp.do_esi = true;
	}
} -start

client c1 {
	txreq -url /1 -hdr "Accept-encoding: gzip"
	rxresp
	expect resp.body == "<html>BC</html>"
	delay .1
	txreq -url /2 -hdr "Accept-encoding: gzip"
	rxresp
	gunzip
	expect resp.body == "<html>BC</html>"
} -run
