varnishtest "Empty and invalid headers"

server s1 {
	rxreq
	txresp
} -start

varnish v1 -arg "-p feature=+http2" -vcl+backend {
} -start

client c1 {
	txreq -url ""
	rxresp
	expect resp.status == 400
} -run

client c1 {
	txreq -req ""
	rxresp
	expect resp.status == 400
} -run

client c1 {
	txreq -proto ""
	rxresp
	expect resp.status == 400
} -run

client c1 {
	stream 1 {
		txreq -url ""
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -scheme ""
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -req ""
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "empty" ""
		rxresp
		expect resp.status == 200
	} -run
} -run

varnish v1 -vsl_catchup

client c1 {
	stream 1 {
		txreq -hdr "foo" " bar"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "foo" " "
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr ":foo" "bar"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "foo" "b\x0car"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "f o" "bar"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "f: o" "bar"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "foo" "bar "
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "foo" "	bar"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run

client c1 {
	stream 1 {
		txreq -hdr "foo" "bar	"
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
} -run
