vtest "Check that Vary headers are stored"

feature persistent_storage

shell "rm -f ${tmpdir}/_.per"

server s1 {
	rxreq
	txresp -hdr "Foo: foo1" -hdr "Vary: foo, bar"
	rxreq
	txresp -hdr "Foo: foo2" -hdr "Vary: foo, bar"
} -start


vinyl v1 \
	-arg "-sdeprecated_persistent,${tmpdir}/_.per,5m" \
	-arg "-pcli_timeout=60" \
	-arg "-pban_lurker_sleep=0" \
	-vcl+backend { } -start

client c1 {
	txreq -url "/foo" -hdr "foo: 1" -hdr "bar: 2"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1001"
	expect resp.http.foo == "foo1"

	txreq -url "/foo" -hdr "foo: 2" -hdr "bar: 1"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1003"
	expect resp.http.foo == "foo2"

} -run

vinyl v1 -expect n_object == 2
server s1 -wait

vinyl v1 -stop
vinyl v1 -start
vinyl v1 -cliok "debug.xid 2000"

vinyl v1 -expect n_vampireobject == 2

client c1 {
	txreq -url "/foo" -hdr "foo: 1" -hdr "bar: 2"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "2001 1002"
	expect resp.http.foo == "foo1"

	txreq -url "/foo" -hdr "foo: 2" -hdr "bar: 1"
	rxresp
	expect resp.status == 200
	expect resp.http.X-Vinyl == "2002 1004"
	expect resp.http.foo == "foo2"

} -run
