[7.2] df683e46f Add std.cache_req_body() coverage
Nils Goroll
nils.goroll at uplex.de
Thu Sep 15 10:51:03 UTC 2022
commit df683e46f38f61dc8807120569e7b6ea96e89f4f
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Sep 15 11:29:22 2022 +0200
Add std.cache_req_body() coverage
Ref c23ef4c3d874871061792add005fdfda9912db43 870f16cebdf2aac9e9a5e0c8d50c4e632528ae54
Closes #3846
diff --git a/bin/varnishtest/tests/c00055.vtc b/bin/varnishtest/tests/c00055.vtc
index 10c87f292..6e97e1d40 100644
--- a/bin/varnishtest/tests/c00055.vtc
+++ b/bin/varnishtest/tests/c00055.vtc
@@ -14,6 +14,9 @@ varnish v1 -vcl+backend {
import std;
sub vcl_recv {
+ if (req.url == "/wrong-sub") {
+ return (pass);
+ }
if (std.cache_req_body(1KB)) {
set req.http.stored = true;
} else {
@@ -27,6 +30,15 @@ varnish v1 -vcl+backend {
}
set resp.http.stored = req.http.stored;
}
+ sub vcl_backend_fetch {
+ if (bereq.url == "/wrong-sub") {
+ if (std.cache_req_body(1KB)) {
+ return (error(200));
+ } else {
+ return (error(503));
+ }
+ }
+ }
} -start
# check log for the aborted POST
@@ -60,6 +72,12 @@ server s1 {
txresp
} -start
+client c1 {
+ txreq -url "/wrong-sub"
+ rxresp
+ expect resp.status == 503
+} -run
+
client c1 {
txreq -url "/is_varnish_still_running"
rxresp
@@ -72,5 +90,16 @@ client c2 {
expect_close
expect resp.http.stored == <undef>
} -run
+
+varnish v1 -errvcl {req.body can only be cached in vcl_recv} {
+ import std;
+ backend none none;
+ sub vcl_init {
+ if (! std.cache_req_body(1KB)) {
+ return (fail);
+ }
+ }
+}
+
varnish v1 -stop
logexpect l1 -wait
More information about the varnish-commit
mailing list