vtest "hash_always_miss overrides hit-for-pass"

server s1 {
	rxreq
	expect req.http.Uncacheable == false
	txresp -hdr "Hit-Pass: forever"

	rxreq
	expect req.http.Uncacheable == true
	txresp

	rxreq
	expect req.http.Uncacheable == false
	txresp
} -start

vinyl v1 -vcl+backend {
	sub vcl_recv {
		set req.hash_always_miss = (req.http.Hash == "always-miss");
	}

	sub vcl_backend_fetch {
		set bereq.http.Uncacheable = bereq.uncacheable;
	}

	sub vcl_backend_response {
		if (beresp.http.Hit-Pass == "forever") {
			return (pass(1y));
		}
	}

	sub vcl_deliver {
		set resp.http.Obj-Hits = obj.hits;
	}
} -start

logexpect l1 -v v1 -g request {
	expect * 1001	VCL_return	lookup
	expect * 1001	VCL_call	MISS
	expect * 1002	TTL		"^HFP 31536000 "
	expect * 1003	VCL_return	lookup
	expect * 1003	VCL_call	PASS
	expect * 1005	VCL_return	lookup
	expect * 1005	VCL_call	MISS
	expect * 1007	VCL_return	lookup
	expect * 1007	VCL_call	HIT
} -start

client c1 {
	txreq
	rxresp
	expect resp.http.Obj-Hits == 0

	delay .1

	txreq
	rxresp
	expect resp.http.Obj-Hits == 0

	delay .1

	txreq -hdr "Hash: always-miss"
	rxresp
	expect resp.http.Obj-Hits == 0

	delay .1

	txreq
	rxresp
	expect resp.http.Obj-Hits == 1
} -run

logexpect l1 -wait
