vtest "Include gzipped and ungzipped (ESI) objects in a gzipped ESI object"

server s1 {
	rxreq
	expect req.http.accept-encoding == gzip
	txresp -gzipbody {
		<html>					1
		Before includes				2
		<esi:include src="/foo"/>		3
		Between includes			4
		<esi:include src="/bar"/>		5
		Between includes			6
		<esi:include src="/fooz"/>		7
		Between includes			8
		<esi:include src="/barz"/>		9
		After includes				10
	}

	rxreq
	expect req.url == "/foo"
	txresp -body {<h1>/////<h2>}

	rxreq
	expect req.url == "/bar"
	txresp -body {*****}

	rxreq
	expect req.http.accept-encoding == gzip
	expect req.url == "/fooz"
	txresp -gzipbody {<h1>-----<h2>}

	rxreq
	expect req.http.accept-encoding == gzip
	expect req.url == "/barz"
	txresp -gzipbody {#####}
} -start

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

vinyl v1 -cliok "param.set http_gzip_support true"
vinyl v1 -cliok "param.set debug +esi_chop"
vinyl v1 -cliok "param.set feature +esi_disable_xml_check"

vinyl v1 -cliok "param.set debug +syncvsl"

client c1 {
	txreq -hdr "Accept-Encoding: gzip"
	rxresp
	expect resp.http.content-encoding == gzip
	gunzip
	expect resp.status == 200
	expect resp.bodylen == 192
}

client c1 -run
vinyl v1 -expect esi_errors == 0
