vtest "Test H2 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
vinyl v1 -cliok "param.set feature +http2"

client c1 {
	stream 1 {
		txreq -url "/foo"
		rxresp
		expect resp.status == 200
		expect resp.http.etag == {"foo"}
		expect resp.http.content-length == "6"
		expect resp.bodylen == 6
	} -run
	delay .1
	stream 3 {
		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
	} -run
	delay .1
	stream 5 {
		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 == 0
	} -run
	delay .1
	stream 7 {
		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 == 0
	} -run
	delay .1
	stream 9 {
		txreq -url "/bar"
		rxresp
		expect resp.status == 200
		expect resp.http.etag == {"bar"}
		expect resp.http.content-length == "0"
		expect resp.bodylen == 0
	} -run
	delay .1
	stream 11 {
		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 == 0
	} -run
}

client c1 -run

# client c1 -run
