varnishtest "#942 junk after gzip from backend"

server s1 {
	rxreq
	txresp -nolen \
		-hdr "Content-Encoding: gzip" \
		-hdr "Connection: close" \
		-hdr "Transfer-Encoding: Chunked"
	send "14\r\n"
		# An empty gzip file:
		sendhex "1f8b"
		sendhex "08"
		sendhex "00"
		sendhex "00000000"
		sendhex "00"
		sendhex "03"
		sendhex "0300"
		sendhex "00000000"
		sendhex "00000000"
	send "\r\n"
	chunked "FOOBAR"
	non_fatal
	chunkedlen 0
} -start

varnish v1 \
	-vcl+backend {
		sub vcl_backend_response {
			set beresp.do_stream = false;
			if (bereq.http.foo == "foo") {
				set beresp.do_gunzip = true;
			}
		}
}

varnish v1 -cliok "param.set debug +syncvsl"
varnish v1 -start

client c1 {
	txreq -url /1
	rxresp
	expect resp.status == 503
} -run

server s1 -wait {
	fatal
	rxreq
	txresp -nolen \
		-hdr "Content-Encoding: gzip" \
		-hdr "Connection: close" \
		-hdr "Transfer-Encoding: Chunked"
	send "14\r\n"
		# An empty gzip file:
		sendhex "1f8b"
		sendhex "08"
		sendhex "00"
		sendhex "00000000"
		sendhex "00"
		sendhex "03"
		sendhex "0300"
		sendhex "00000000"
		sendhex "00000000"
	send "\r\n"
	chunked "FOOBAR"
	non_fatal
	chunkedlen 0
} -start


client c1 {
	txreq -url /2 -hdr "Foo: foo"
	rxresp
	expect resp.status == 503
} -run

