vtest "Backend IMS header merging"

server s1 {
	rxreq
	txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
		-hdr "Foobar: foo" \
		-hdr "Snafu: 1" \
		-bodylen 13
	rxreq
	expect req.http.if-modified-since == "Thu, 26 Jun 2008 12:00:01 GMT"
	txresp -status "304" \
		-hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
		-hdr "Snafu: 2" \
		-hdr "Grifle: 3" \
		-nolen

} -start

vinyl v1 -vcl+backend {
	sub vcl_backend_response {
		set beresp.grace = 0s;
		set beresp.keep = 60s;
		set beresp.ttl = 1s;
		if (beresp.http.foobar == "foo") {
			set beresp.http.foobar = "foo0";
		}
		if (beresp.http.snafu == "2") {
			set beresp.http.snafu = "2a";
		}
	}
} -start

client c1 {
	txreq
	rxresp
	expect resp.bodylen == 13
	expect resp.http.foobar == foo0
	expect resp.http.snafu == 1
	delay 3
	txreq
	rxresp
	expect resp.bodylen == 13
	expect resp.http.foobar == foo0
	expect resp.http.grifle == 3
	expect resp.http.snafu == 2a
} -run

