vtest "Test Client IMS"

server s1 {
	rxreq
	expect req.url == "/foo"
	txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
	    -hdr {ETag: "foo"} \
	    -body "11111\n"
	rxreq
	expect req.url == "/bar"
	txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
	    -hdr {ETag: "bar"}
} -start

vinyl v1 -vcl+backend { } -start

client c1 {
	txreq -url "/foo"
	rxresp
	expect resp.status == 200
	expect resp.http.etag == {"foo"}
	expect resp.http.content-length == "6"
	expect resp.bodylen == 6

	txreq -url "/foo" \
	    -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT"
	rxresp
	expect resp.status == 200
	expect resp.http.content-length == "6"
	expect resp.http.etag == {"foo"}
	expect resp.bodylen == 6

	txreq -url "/foo" \
	    -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
	rxresp -no_obj
	expect resp.status == 304
	expect resp.http.etag == {"foo"}
	expect resp.http.content-length == "<undef>"
	expect resp.bodylen == "<undef>"

	txreq -url "/foo" \
	    -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:02 GMT"
	rxresp -no_obj
	expect resp.status == 304
	expect resp.http.etag == {"foo"}
	expect resp.http.content-length == "<undef>"
	expect resp.bodylen == "<undef>"

	txreq -url "/bar"
	rxresp
	expect resp.status == 200
	expect resp.http.etag == {"bar"}
	expect resp.http.content-length == "0"
	expect resp.bodylen == 0

	txreq -url "/bar" \
	    -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
	rxresp -no_obj
	expect resp.status == 304
	expect resp.http.etag == {"bar"}
	expect resp.http.content-length == <undef>
	expect resp.bodylen == <undef>
}

client c1 -run

client c1 -run
