[master] 02a78f2d5 vrb: Send a minimal 400 response for cached req body failures

Walid Boudebouda walid.boudebouda at gmail.com
Mon Jul 21 13:04:05 UTC 2025


commit 02a78f2d53bfbec59f2a8bb92e5f8eceb91f0a95
Author: Walid Boudebouda <walid.boudebouda at gmail.com>
Date:   Fri Jul 18 11:59:45 2025 +0200

    vrb: Send a minimal 400 response for cached req body failures
    
    This makes it symmetric with the streamed req body case.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 803810210..a8fa68be9 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -1007,6 +1007,7 @@ cnt_recv(struct worker *wrk, struct req *req)
 	/* Attempts to cache req.body may fail */
 	if (req->req_body_status == BS_ERROR) {
 		req->doclose = SC_RX_BODY;
+		(void)req->transport->minimal_response(req, 400);
 		return (REQ_FSM_DONE);
 	}
 
diff --git a/bin/varnishtest/tests/c00055.vtc b/bin/varnishtest/tests/c00055.vtc
index 048421967..a84f61f90 100644
--- a/bin/varnishtest/tests/c00055.vtc
+++ b/bin/varnishtest/tests/c00055.vtc
@@ -72,5 +72,6 @@ client c4 {
 # req body overflow
 client c5 {
 	txreq -req POST -hdr "Content-Length: 1025"
-	expect_close
+	rxresp
+	expect resp.status == 400
 } -run
diff --git a/bin/varnishtest/tests/c00067.vtc b/bin/varnishtest/tests/c00067.vtc
index 71e8c90f0..ebfeebff7 100644
--- a/bin/varnishtest/tests/c00067.vtc
+++ b/bin/varnishtest/tests/c00067.vtc
@@ -91,7 +91,8 @@ client c1 {
 	chunked {BLAST}
 	delay .2
 	chunkedlen 106
-	expect_close
+	rxresp
+	expect resp.status == 400
 } -run
 
 logexpect l2 -wait
diff --git a/bin/varnishtest/tests/f00016.vtc b/bin/varnishtest/tests/f00016.vtc
index d0ffc93d2..322bff7e8 100644
--- a/bin/varnishtest/tests/f00016.vtc
+++ b/bin/varnishtest/tests/f00016.vtc
@@ -67,3 +67,24 @@ client c4 {
 } -run
 
 logexpect l1 -wait
+
+varnish v1 -vcl+backend {
+	import std;
+
+	sub vcl_recv {
+		std.cache_req_body(10kb);
+	}
+}
+
+client c5 {
+	non_fatal
+	txreq -req POST -hdr "Transfer-encoding: chunked"
+	send "1\r\n"
+	send "This is more than one byte of data\r\n"
+	send "0\r\n"
+	send "\r\n"
+	fatal
+	rxresp
+	expect resp.status == 400
+	expect_close
+} -run


More information about the varnish-commit mailing list