varnishtest "#2351: :path/:method error handling"

server s1 {
	rxreq
	txresp
} -start

varnish v1 -vcl+backend {} -start
varnish v1 -cliok "param.set feature +http2"
varnish v1 -cliok "param.set debug +syncvsl"

client c1 {
	# missing everything
	stream 1 {
		txreq -noadd
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run

	# missing :path
	stream 3 {
		txreq -noadd -hdr ":authority" "example.com"  -hdr ":method" "GET" -hdr ":scheme" "http"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run

	# missing :method
	stream 5 {
		txreq -noadd -hdr ":authority" "example.com"  -hdr ":path" "/foo" -hdr ":scheme" "http"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run

	# Duplicate :path
	stream 7 {
		txreq -noadd -hdr ":path" "/" -hdr ":path" "/foo" -hdr ":method" "GET" -hdr ":authority" "example.com" -hdr ":scheme" "http"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

varnish v1 -expect MEMPOOL.req0.live == 0
varnish v1 -expect MEMPOOL.req1.live == 0
varnish v1 -expect MEMPOOL.sess0.live == 0
varnish v1 -expect MEMPOOL.sess1.live == 0
