[master] a6d082142 v1f: Reply 400 to request body failures

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


commit a6d082142cab7cb28aa44dc83c7d5c7cc50f6c62
Author: Walid Boudebouda <walid.boudebouda at gmail.com>
Date:   Fri Jul 18 11:54:08 2025 +0200

    v1f: Reply 400 to request body failures
    
    This is a client error that should get an appropriate 400
    response instead of a generic 503.
    
    Fixes #4329

diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index e0c53b96b..f8bcf43cd 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -162,6 +162,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
 			    "req.body read error: %d (%s)",
 			    errno, VAS_errtxt(errno));
 			bo->req->doclose = SC_RX_BODY;
+			bo->err_code = 400;
 		}
 		if (cl < 0)
 			V1L_EndChunk(v1l);
diff --git a/bin/varnishtest/tests/f00001.vtc b/bin/varnishtest/tests/f00001.vtc
index 2c756c9cd..2cab540ba 100644
--- a/bin/varnishtest/tests/f00001.vtc
+++ b/bin/varnishtest/tests/f00001.vtc
@@ -18,7 +18,7 @@ client c1 {
 	send "0\r\n\r\n"
 
 	rxresp
-	expect resp.status == 503
+	expect resp.status == 400
 } -run
 
 # Check that the published workaround does not cause harm
diff --git a/bin/varnishtest/tests/f00016.vtc b/bin/varnishtest/tests/f00016.vtc
index a38b8b1ef..d0ffc93d2 100644
--- a/bin/varnishtest/tests/f00016.vtc
+++ b/bin/varnishtest/tests/f00016.vtc
@@ -23,7 +23,7 @@ client c1 {
 	send "\r\n"
 	fatal
 	rxresp
-	expect resp.status == 503
+	expect resp.status == 400
 	expect_close
 } -run
 
@@ -38,7 +38,7 @@ client c2 {
 	send "\r\n"
 	fatal
 	rxresp
-	expect resp.status == 503
+	expect resp.status == 400
 	expect_close
 } -run
 
@@ -51,7 +51,7 @@ client c3 {
 	send "\r\n"
 	fatal
 	rxresp
-	expect resp.status == 503
+	expect resp.status == 400
 	expect_close
 } -run
 
@@ -62,7 +62,7 @@ client c4 {
 	send "\r\n"
 	fatal
 	rxresp
-	expect resp.status == 503
+	expect resp.status == 400
 	expect_close
 } -run
 
diff --git a/bin/varnishtest/tests/r02722.vtc b/bin/varnishtest/tests/r02722.vtc
index 1268864b5..ac1027823 100644
--- a/bin/varnishtest/tests/r02722.vtc
+++ b/bin/varnishtest/tests/r02722.vtc
@@ -18,7 +18,7 @@ client c1 {
         txreq -req POST -hdr "Content-Length: 100"
         send some
         rxresp
-        expect resp.status == 503
+        expect resp.status == 400
 }
 
 # This run performs the inheritance test on a TCP connection


More information about the varnish-commit mailing list