vtest "Empty and invalid headers"

server s1 {
	rxreq
	txresp
} -start

vinyl 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
	stream 3 {
		txreq
		rxresp
		expect resp.status == 200
	} -run
} -run

client c1 {
	stream 1 {
		txreq -scheme ""
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
	stream 3 {
		txreq
		rxresp
		expect resp.status == 200
	} -run
} -run

client c1 {
	stream 1 {
		txreq -req ""
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
	stream 3 {
		txreq
		rxresp
		expect resp.status == 200
	} -run
} -run

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

vinyl v1 -vsl_catchup

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

client c1 {
	stream 1 {
		txreq -hdr "foo" " "
		rxrst
		expect rst.err == PROTOCOL_ERROR
	} -run
	stream 3 {
		txreq
		rxresp
		expect resp.status == 200
	} -run
} -run

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

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

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

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

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

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

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