varnishtest "H/2 stream early buffer exhaustion"

barrier b1 sock 2

server s1 {
	rxreq
	txresp
} -start

varnish v1 -vcl+backend {
	import vtc;
	sub vcl_recv {
		vtc.barrier_sync("${b1_sock}");
		vtc.sleep(0.1s);
	}
} -start

varnish v1 -cliok "param.set fetch_chunksize 64k"
varnish v1 -cliok "param.set feature +http2"
varnish v1 -cliok "param.reset h2_initial_window_size"
varnish v1 -cliok "param.reset h2_rx_window_low_water"

client c1 {
	stream 1 {
		txreq -req POST -url /1 -hdr "content-length" "131072" -nostrend

		expect stream.peer_window == 65535
		txdata -datalen 16384 -nostrend
		txdata -datalen 16384 -nostrend
		txdata -datalen 16384 -nostrend
		txdata -datalen 16383 -nostrend
		expect stream.peer_window == 0
		barrier b1 sync

		loop 4 {
			rxwinup
			expect stream.peer_window == 65535
			txdata -datalen 16384 -nostrend
		}

		rxwinup
		expect stream.peer_window == 65535
		txdata -datalen 1

		rxresp
		expect resp.status == 200
	} -run
} -run
