vtest "Set the storage backend for the request body"

server s1 {
	rxreq
	expect req.bodylen == 100
	txresp
	rxreq
	expect req.bodylen == 100
	txresp
} -start

vinyl v1 \
    -arg "-s default,1MB" \
    -arg "-s default,1MB" \
    -arg "-s Transient=default" \
    -syntax 4.0 \
    -vcl+backend {
	import std;
	sub vcl_recv {
		if (req.url == "/1") {
			set req.storage = storage.s1;
		}
		std.cache_req_body(1KB);
	}
	sub vcl_backend_fetch {
		return (fetch);
	}
	sub vcl_backend_response {
		set beresp.storage = storage.s0;
	}
}

# -cli because accept_filter may not be supported
vinyl v1 -cli "param.set accept_filter off"

vinyl v1 -start

client c1 {
	txreq -url /0 -bodylen 100
	rxresp
} -run

vinyl v1 -expect SM?.s0.c_bytes > 0
vinyl v1 -expect SM?.s1.c_bytes == 0
vinyl v1 -expect SM?.Transient.c_bytes > 0

client c1 {
	txreq -url /1 -bodylen 100
	rxresp
} -run

vinyl v1 -expect SM?.s0.c_bytes > 0
vinyl v1 -expect SM?.s1.c_bytes > 0
vinyl v1 -expect SM?.Transient.c_bytes > 0
