[master] 478e310a7 vmod_std: use $Restrict where relevant
Nils Goroll
nils.goroll at uplex.de
Mon Apr 24 13:46:09 UTC 2023
commit 478e310a7d2c168e1c361d6f34291177cbc2a889
Author: Walid Boudebouda <walid.boudebouda at gmail.com>
Date: Fri Mar 17 17:11:39 2023 +0100
vmod_std: use $Restrict where relevant
diff --git a/bin/varnishtest/tests/c00055.vtc b/bin/varnishtest/tests/c00055.vtc
index e5609f35d..048421967 100644
--- a/bin/varnishtest/tests/c00055.vtc
+++ b/bin/varnishtest/tests/c00055.vtc
@@ -17,9 +17,7 @@ varnish v1 -vcl+backend {
import std;
sub vcl_recv {
- if (req.url != "/wrong-sub") {
- set req.http.stored = std.cache_req_body(1KB);
- }
+ set req.http.stored = std.cache_req_body(1KB);
return (pass);
}
@@ -30,15 +28,6 @@ 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
varnish v1 -cliok "param.set debug +syncvsl"
@@ -63,13 +52,6 @@ client c2 {
logexpect l1 -wait
-# wrong calling context
-client c3 {
- txreq -url "/wrong-sub"
- rxresp
- expect resp.status == 503
-} -run
-
delay .1
varnish v1 -expect MGT.child_died == 0
@@ -92,13 +74,3 @@ client c5 {
txreq -req POST -hdr "Content-Length: 1025"
expect_close
} -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);
- }
- }
-}
diff --git a/vmod/tests/std_c00001.vtc b/vmod/tests/std_c00001.vtc
index 57158b020..66d931b25 100644
--- a/vmod/tests/std_c00001.vtc
+++ b/vmod/tests/std_c00001.vtc
@@ -358,7 +358,7 @@ varnish v1 -errvcl {Not available in subroutine 'vcl_pipe'} {
# We would want to remove req from vcl_pipe, but that could break
# vmods, so we fail specifically at runtime
-varnish v1 -vcl {
+varnish v1 -errvcl {Not available in subroutine 'vcl_pipe'} {
import std;
backend proforma None;
@@ -371,9 +371,3 @@ varnish v1 -vcl {
}
}
-client c7 {
- txreq -url /
- rxresp
- expect resp.status == 503
- expect resp.reason == "VCL failed"
-} -run
diff --git a/vmod/vmod_std.c b/vmod/vmod_std.c
index 14932b0ef..72f84e9ef 100644
--- a/vmod/vmod_std.c
+++ b/vmod/vmod_std.c
@@ -270,12 +270,7 @@ VCL_VOID v_matchproto_(td_std_late_100_continue)
vmod_late_100_continue(VRT_CTX, VCL_BOOL late)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (ctx->method != VCL_MET_RECV) {
- VSLb(ctx->vsl, SLT_VCL_Error,
- "std.late_100_continue() only valid in vcl_recv{}");
- return;
- }
-
+ AN(ctx->method & VCL_MET_RECV);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
if (ctx->req->want100cont)
ctx->req->late100cont = late;
diff --git a/vmod/vmod_std.vcc b/vmod/vmod_std.vcc
index 04130136d..47f319b4d 100644
--- a/vmod/vmod_std.vcc
+++ b/vmod/vmod_std.vcc
@@ -521,6 +521,8 @@ Example::
...
}
+$Restrict vcl_recv
+
$Function VOID late_100_continue(BOOL late)
Controls when varnish reacts to an ``Expect: 100-continue`` client
@@ -555,6 +557,8 @@ Example::
...
}
+$Restrict vcl_recv
+
$Function VOID set_ip_tos(INT tos)
Sets the Differentiated Services Codepoint (DSCP) / IPv4 Type of
@@ -572,6 +576,8 @@ Example::
std.set_ip_tos(0);
}
+$Restrict client
+
$Function VOID rollback(HTTP h)
Restores the *h* HTTP headers to their original state.
@@ -580,6 +586,8 @@ Example::
std.rollback(bereq);
+$Restrict backend vcl_recv vcl_pass vcl_hash vcl_purge vcl_miss vcl_hit vcl_deliver vcl_synth
+
$Function BOOL ban(STRING)
Invalidates all objects in cache that match the given expression with
More information about the varnish-commit
mailing list