varnishtest "Check that we handle bogusly large chunks correctly"

# Check that the bug has been fixed

server s1 {
	rxreq
	txresp
} -start

varnish v1 -vcl+backend {
} -start

client c1 {
	send "POST / HTTP/1.1\r\n"
	send "Host: foo\r\n"
	send "Transfer-Encoding: chunked\r\n\r\n"
	send "FFFFFFFFFFFFFFED\r\n"
	send "0\r\n\r\n"

	rxresp
	expect resp.status == 503
} -run

# Check that the published workaround does not cause harm

varnish v1 -vcl+backend {
	sub vcl_recv {
		if (req.http.transfer-encoding ~ "(?i)chunked") {
			return (fail);
		}
	}
}

client c1 {
	send "POST / HTTP/1.1\r\n"
	send "Host: foo\r\n"
	send "Transfer-Encoding: chunked\r\n\r\n"
	send "FFFFFFFFFFFFFFED\r\n"

	rxresp
	expect resp.status == 503
} -run
