[master] 948de55 promote resp.body / beresp.body syntax a bit more

Nils Goroll nils.goroll at uplex.de
Wed Apr 18 09:56:09 UTC 2018


commit 948de551d855879ccedcac52e15784b7f0abf7ff
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Apr 18 11:54:31 2018 +0200

    promote resp.body / beresp.body syntax a bit more
    
    Should we plan to phase out synthetic() ?

diff --git a/bin/varnishtest/tests/b00017.vtc b/bin/varnishtest/tests/b00017.vtc
index 42c96fe..29fbe9e 100644
--- a/bin/varnishtest/tests/b00017.vtc
+++ b/bin/varnishtest/tests/b00017.vtc
@@ -9,7 +9,7 @@ varnish v1 -vcl {
 	}
 
 	sub vcl_synth {
-		synthetic("Custom vcl_synth's synth output");
+		set resp.body = "Custom vcl_synth's body";
 		return (deliver);
 	}
 } -start
@@ -18,8 +18,9 @@ client c1 {
 	txreq -url "/"
 	rxresp
 	expect resp.status == 888
-	expect resp.bodylen == 31
 	expect resp.http.connection != close
+	expect resp.bodylen == 23
+	expect resp.body == "Custom vcl_synth's body"
 } -run
 
 varnish v1 -expect s_synth == 1
diff --git a/bin/varnishtest/tests/c00063.vtc b/bin/varnishtest/tests/c00063.vtc
index b5c2cfe..5b0a61e 100644
--- a/bin/varnishtest/tests/c00063.vtc
+++ b/bin/varnishtest/tests/c00063.vtc
@@ -8,7 +8,7 @@ varnish v1 -vcl {
 		set beresp.ttl = 1s;
 		set beresp.grace = 3s;
 		set beresp.http.foobar = "BLA" + bereq.xid;
-		synthetic(beresp.http.foobar);
+		set beresp.body = beresp.http.foobar;
 		return (deliver);
 	}
 } -start
@@ -24,9 +24,11 @@ client c1 {
 	txreq
 	rxresp
 	expect resp.http.foobar == "BLA1002"
+	expect resp.body == "BLA1002"
 
 	delay 3
 	txreq
 	rxresp
 	expect resp.http.foobar == "BLA1004"
+	expect resp.body == "BLA1004"
 } -run
diff --git a/bin/varnishtest/tests/c00068.vtc b/bin/varnishtest/tests/c00068.vtc
index 313ca9b..88a47b6 100644
--- a/bin/varnishtest/tests/c00068.vtc
+++ b/bin/varnishtest/tests/c00068.vtc
@@ -37,7 +37,7 @@ varnish v1 -vcl+backend {
 				return (restart);
 			} else {
 				set resp.http.restarts = req.restarts;
-				synthetic(req.restarts);
+				set resp.body = req.restarts;
 			}
 		}
 		return (deliver);
diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc
index f554a01..c418b8f 100644
--- a/bin/varnishtest/tests/m00004.vtc
+++ b/bin/varnishtest/tests/m00004.vtc
@@ -42,8 +42,8 @@ varnish v1 -vcl+backend {
 	}
 
 	sub vcl_synth {
-		synthetic("Response was served by "
-			  + std.fileread("${tmpdir}/m00004_file_four"));
+		set resp.body = "Response was served by "
+			+ std.fileread("${tmpdir}/m00004_file_four");
 		return(deliver);
 	}
 } -start
@@ -111,8 +111,8 @@ varnish v1 -vcl+backend {
 	}
 
 	sub vcl_synth {
-		synthetic("Response was served by "
-			  + std.fileread("${tmpdir}/m00004_file_four"));
+		set resp.body = "Response was served by "
+			+ std.fileread("${tmpdir}/m00004_file_four");
 		return(deliver);
 	}
 }
diff --git a/bin/varnishtest/tests/r01688.vtc b/bin/varnishtest/tests/r01688.vtc
index fd0373b..bb4c92d 100644
--- a/bin/varnishtest/tests/r01688.vtc
+++ b/bin/varnishtest/tests/r01688.vtc
@@ -18,7 +18,8 @@ varnish v1 -vcl+backend {
 
 	sub vcl_synth {
 	  if (resp.status == 998) {
-	    synthetic("this is the body of an included synthetic response");
+	    set resp.body = "this is the body of an " +
+		"included synthetic response";
 	    return(deliver);
 	  }
 	}
diff --git a/bin/varnishtest/tests/r01838.vtc b/bin/varnishtest/tests/r01838.vtc
index ce1f20b..077851f 100644
--- a/bin/varnishtest/tests/r01838.vtc
+++ b/bin/varnishtest/tests/r01838.vtc
@@ -14,7 +14,7 @@ varnish v1 -vcl+backend {
 
 	sub vcl_synth {
 		if (resp.status == 998) {
-			synthetic("synthetic body");
+			set resp.body = "synthetic body";
 			return (deliver);
 		}
 	}
diff --git a/bin/varnishtest/tests/r02429.vtc b/bin/varnishtest/tests/r02429.vtc
index 81e42f0..3eb1b6e 100644
--- a/bin/varnishtest/tests/r02429.vtc
+++ b/bin/varnishtest/tests/r02429.vtc
@@ -6,7 +6,7 @@ server s1 {
 
 varnish v1 -arg "-s Transient=file,${tmpdir}/_.file,10m" -vcl+backend {
 	sub vcl_backend_error {
-		synthetic("foo");
+		set beresp.body = "foo";
 		return (deliver);
 	}
 } -start
diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst
index d2263dc..9137757 100644
--- a/doc/sphinx/reference/vcl.rst
+++ b/doc/sphinx/reference/vcl.rst
@@ -467,8 +467,10 @@ hash_data(input)
 synthetic(STRING)
 ~~~~~~~~~~~~~~~~~
 
-  Prepare a synthetic response body containing the *STRING*. Available in
-  ``vcl_synth`` and ``vcl_backend_error``.
+  Prepare a synthetic response body containing the *STRING*. Available
+  in ``vcl_synth`` and ``vcl_backend_error``.
+
+  Identical to ``set resp.body`` /  ``set beresp.body``.
 
 .. list above comes from struct action_table[] in vcc_action.c.
 


More information about the varnish-commit mailing list