vtest  "Regression test for #1684"
server s1 {
	rxreq
	txresp -hdr "foo: 1"
	accept
	rxreq
	txresp -hdr "foo: 2"
	accept
	rxreq
	txresp -hdr "foo: 3"
} -start

vinyl v1 -vcl+backend {
	sub vcl_recv { return (pass); }
	sub vcl_backend_response {
		set beresp.http.bar = bereq.retries;
		if (beresp.http.foo != bereq.http.stop) {
			return (retry);
		}
	}
} -start

# check log for the aborted POST
logexpect l1 -v v1 -g request {
	expect * *	Begin		"^bereq .* retry"
	expect * =	BereqHeader	"^X-Vinyl:"
	expect * =	BereqUnset	"^X-Vinyl:"
	expect * =	BereqHeader	"^X-Vinyl:"
} -start

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

client c1 {
	txreq -hdr "stop: 3"
	rxresp
	expect resp.http.foo == 3
} -run

logexpect l1 -wait
