vtest "obj.ttl relative/absolute"

server s1 {
	rxreq
	txresp -hdr "Cache-Control: max-age=23" -hdr "Age: 4" -bodylen 40
} -start

vinyl v1 -vcl+backend {
	sub vcl_backend_response {
		set beresp.http.fooA = beresp.ttl;
		set beresp.ttl = 10s;
		set beresp.http.fooB = beresp.ttl;
		set beresp.http.ageA = beresp.age;
	}
	sub vcl_hit {
		set req.http.foo = obj.ttl;
		set req.http.ageB = obj.age;
	}
	sub vcl_deliver {
		set resp.http.foo = req.http.foo;
		set resp.http.ageB = req.http.ageB;
	}
} -start

client c1 {
	txreq
	rxresp
	expect resp.bodylen == 40
	expect resp.http.fooA == 19.000
	expect resp.http.fooB == 10.000
	expect resp.http.ageA == 4.000

	delay 2
	txreq
	rxresp
	expect resp.bodylen == 40
	expect resp.http.fooA == 19.000
	expect resp.http.fooB == 10.000
	expect resp.http.foo <= 8.000
	expect resp.http.ageA == 4.000
	expect resp.http.ageB >= 6.000

	delay 2
	txreq
	rxresp
	expect resp.bodylen == 40
	expect resp.http.fooA == 19.000
	expect resp.http.fooB == 10.000
	expect resp.http.foo <= 6.000
	expect resp.http.ageA == 4.000
	expect resp.http.ageB >= 8.000
} -run
