varnishtest "Check Range forwarding to backend"

server s1 {
	rxreq
	expect req.url == "/foo"
	expect req.http.range == <undef>
	txresp \
		-hdr "Foobar: _barf_" \
		-hdr "Connection: close" \
		-body "012345\n"

	accept

	rxreq
	expect req.url == "/bar"
	expect req.http.range == "200-300"
	txresp \
		-status 206 \
		-hdr "Foobar: _barf_" \
		-body "012345\n"
} -start

varnish v1 -vcl+backend {
	sub vcl_recv {
		if (req.url ~ "bar") {
			return(pass);
		}
	}
} -start

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

client c1 {
	txreq -url "/foo" -hdr "Range: bytes=1-2"
	rxresp
	expect resp.status == 206
	expect resp.http.Content-Length == 2
	expect resp.http.X-Varnish == "1001"
} -run

varnish v1 -cliok "param.set http_range_support off"

client c2 {
	# NB: Deliberately bogus Range header
	txreq -url "/bar" -hdr "Range: 200-300"
	rxresp
	expect resp.status == 206
	expect resp.http.X-Varnish == "1004"
} -run
